# ================================================
760227
public function route()
	{
		try
		{
			$dispatcher = new dispatcher( $this->router->getData() );
			$results = $dispatcher->dispatch( $this->request->method(), parse_url($this->request->base_url(), PHP_URL_PATH) );
		}
		catch( \Exception $e )
		{
			switch( get_class($e) )
			{
				case 'Phroute\Phroute\Exception\HttpRouteNotFoundException':
					http_response_code(404);
					break;
				case 'Phroute\Phroute\Exception\HttpMethodNotAllowedException':
					http_response_code(403);
					break;
				default:
					print_r($e);
					http_response_code(400);
					break;
			}
		}
	}
431455
public function edit($id)
    {
        if (!$this->request->is(['get', 'put'])) {
            throw new MethodNotAllowedException();
        }

        /** @var User $user */
        $user = $this->Users->getUserAndGroups($id);

        if ($this->request->is('put')) {
            $user = $this->Users->patchEntity($user, $this->request->data, ['associated' => 'Groups']);
            $userActivated = ($user->dirty('active') && $user->active);
            if ($userActivated) {
                // do not allow a user to be activated if his email address is not verified
                if (!$user->verified) {
                    $user->active = false;
                    $userActivated = false;
                } else {
                    $user->activate();
                }
            }
            $userDeactivated = ($user->dirty('active') && !$user->active);
            if ($userDeactivated) {
                // do not allow a user to deactivate his own account
                if ($user->id === Wasabi::user()->id) {
                    $user->active = true;
                    $userDeactivated = false;
                } else {
                    $user->deactivate();
                }
            }
            if ($this->Users->save($user, ['associated' => 'Groups'])) {
                if ($user->id === Wasabi::user()->id) {
                    $updateUser = $this->Users->get($user->id);
                    $updateUser->group_id = $this->Users->UsersGroups->getGroupIds($updateUser->id);
                    $this->Auth->setUser($updateUser->toArray());
                    Wasabi::user($updateUser);
                }
                if ($userActivated && $user->verified) {
                    $this->getMailer('Wasabi/Core.User')->send('activatedEmail', [$user]);
                }
                if ($userDeactivated && $user->verified) {
                    $this->getMailer('Wasabi/Core.User')->send('deactivatedEmail', [$user]);
                }
                $this->Flash->success(__d('pb', 'The user <strong>{0}</strong> has been updated.', $user->fullName()));
                $this->redirect($this->Filter->getBacklink(['action' => 'index'], $this->request));
                return;
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        }

        $groups = $this->Users->Groups->find('list')->order('id ASC');

        // users that are no admin, may not select the admin group
        if (Wasabi::user()->hasAccessLevel(Permission::OWN)) {
            $groups->where(['id <>' => 1]);
        }

        $this->set([
            'user' => $user,
            'groups' => $groups,
            'languages' => Hash::map(Configure::read('languages.backend'), '{n}', function ($language) {
                return [
                    'value' => $language->id,
                    'text' => $language->name
                ];
            })
        ]);

        $this->render('add');
    }
582793
public function execute()
    {
        $min = func_get_arg(0);
        
        $result = $this->value >= $min;
        
        if (!$result) {
            $this->msg = [
                'validator.rule.numbermin',
                $min
            ];
        }
    }
886466
public function index()
    {
        //  Set method info
        $this->data['page']->title = 'Manage ' . ucfirst($this->data['postNamePlural']);

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

        $sTableAlias = $this->blog_post_model->getTableAlias();

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

        //  Get pagination and search/sort variables
        $iPage      = (int) $this->input->get('page') ? (int) $this->input->get('page') : 0;
        $iPerPage   = (int) $this->input->get('perPage') ? (int) $this->input->get('perPage') : 50;
        $sSortOn    = $this->input->get('sortOn') ? $this->input->get('sortOn') : $sTableAlias . '.published';
        $sSortOrder = $this->input->get('sortOrder') ? $this->input->get('sortOrder') : 'desc';
        $sKeywords  = $this->input->get('keywords') ? $this->input->get('keywords') : '';

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

        //  Define the sortable columns
        $aSortColumns = array(
            $sTableAlias . '.published' => 'Published Date',
            $sTableAlias . '.modified'  => 'Modified Date',
            $sTableAlias . '.title'     => 'Title'
        );

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

        //  Checkbox filters
        $aCbFilters   = array();
        $aCbFilters[] = Helper::searchFilterObject(
            $sTableAlias . '.is_published',
            'State',
            array(
                array('Published', true, true),
                array('Unpublished', false, true)
            )
        );

        //  Generate options
        $filterOpts = array();
        foreach ($this->data['postTypes'] as $sValue => $sLabel) {
            $filterOpts[] = array($sLabel, $sValue, true);
        }

        $aCbFilters[] = Helper::searchFilterObject(
            $sTableAlias . '.type',
            'Type',
            $filterOpts
        );

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

        //  Define the $aData variable for the queries
        $aData = array(
            'where' => array(
                array(
                    'column' => 'blog_id',
                    'value' => $this->blog->id
                )
            ),
            'sort' => array(
                array($sSortOn, $sSortOrder)
            ),
            'keywords' => $sKeywords,
            'cbFilters' => $aCbFilters
        );

        //  Get the items for the page
        $iTotalRows          = $this->blog_post_model->countAll($aData);
        $this->data['posts'] = $this->blog_post_model->getAll($iPage, $iPerPage, $aData);

        //  Set Search and Pagination objects for the view
        $this->data['search']     = Helper::searchObject(true, $aSortColumns, $sSortOn, $sSortOrder, $iPerPage, $sKeywords, $aCbFilters);
        $this->data['pagination'] = Helper::paginationObject($iPage, $iPerPage, $iTotalRows);

        //  Add a header button
        if (userHasPermission('admin:blog:post:' . $this->blog->id . ':create')) {

            Helper::addHeaderButton(
                'admin/blog/post/create/' . $this->blog->id,
                'New ' . ucfirst($this->data['postName'])
            );
        }

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

        Helper::loadView('index');
    }
1345774
public function start()
    {
        $one_pixel_image = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wgARCAABAAEDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACP/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAVSf/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABBQJ//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPwF//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPwF//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAGPwJ//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPyF//9oADAMBAAIAAwAAABCf/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAgEBPxB//8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPxB//9k=';

        $array = [
            $this->request->get('msg'),
            'File: ' . $this->request->get('file'),
            'Line: ' . $this->request->get('line'),
            'Col: ' . $this->request->get('col'),
            'Err: ' . $this->request->get('err'),
        ];

        $log = LoggerFactory::create('JSErr');

        $log->error(implode(' | ', $array));

        echo $one_pixel_image;
    }
841278
public function parse()
    {
        $args = $this->formatInputArguments();

        foreach ($args as $key => $value) {
            if ('--' === substr($value, 0, 2)) {
                $this->parseOption(substr($value, 2));
            } else if ('-' === substr($value, 0, 1)) {
                $this->parseOption(substr($value, 1));
            } else {
                $this->parseArgument($value);
            }
        }
    }
1293703
public function initialize() {
        parent::initialize();

        $this->addClauses([
            self::DISTINCT_ON   => 'DISTINCT ON (%s)',
            self::JOIN_STRAIGHT => 'INNER JOIN %s ON %s',
            self::MATCH         => '%s',
            self::NOT_REGEXP    => '%s !~* ?',
            self::RETURNING     => 'RETURNING %s',
            self::REGEXP        => '%s ~* ?',
            self::RLIKE         => '%s ~* ?',
            self::UNIQUE_KEY    => 'UNIQUE (%2$s)',
            self::WITH          => '%s'
        ]);

        $this->addKeywords([
            self::CONCURRENTLY      => 'CONCURRENTLY',
            self::CONTINUE_IDENTITY => 'CONTINUE IDENTITY',
            self::DELETE_ROWS       => 'DELETE ROWS',
            self::DROP              => 'DROP',
            self::FOR_SHARE_LOCK    => 'FOR SHARE',
            self::FOR_UPDATE_LOCK   => 'FOR UPDATE',
            self::INHERITS          => 'INHERITS',
            self::IS_GLOBAL         => 'GLOBAL',
            self::LOCAL             => 'LOCAL',
            self::MATCH_FULL        => 'MATCH FULL',
            self::MATCH_PARTIAL     => 'MATCH PARTIAL',
            self::MATCH_SIMPLE      => 'MATCH SIMPLE',
            self::ON_COMMIT         => 'ON COMMIT',
            self::ONLY              => 'ONLY',
            self::PRESERVE_ROWS     => 'PRESERVE ROWS',
            self::RESTART_IDENTITY  => 'RESTART IDENTITY',
            self::SET_DEFAULT       => 'SET DEFAULT',
            self::TABLESPACE        => 'TABLESPACE',
            self::UNIQUE            => 'UNIQUE',
            self::UNLOGGED          => 'UNLOGGED',
            self::WITH_OIDS         => 'WITH OIDS',
            self::WITHOUT_OIDS      => 'WITHOUT OIDS'
        ]);

        $this->addStatements([
            Query::INSERT        => new Statement('INSERT INTO {table} {fields} VALUES {values}'),
            Query::SELECT        => new Statement('SELECT {distinct} {fields} FROM {table} {joins} {where} {groupBy} {having} {compounds} {orderBy} {limit} {lock}'),
            Query::UPDATE        => new Statement('UPDATE {only} {table} SET {fields} {where}'),
            Query::DELETE        => new Statement('DELETE FROM {only} {table} {joins} {where}'),
            Query::TRUNCATE      => new Statement('TRUNCATE {only} {table} {identity} {action}'),
            Query::CREATE_TABLE  => new Statement("CREATE {type} {temporary} {unlogged} TABLE IF NOT EXISTS {table} (\n{columns}{keys}\n) {options}"),
            Query::CREATE_INDEX  => new Statement('CREATE {type} INDEX {concurrently} {index} ON {table} ({fields})'),
            Query::DROP_TABLE    => new Statement('DROP TABLE IF EXISTS {table} {action}'),
            Query::DROP_INDEX    => new Statement('DROP INDEX {concurrently} IF EXISTS {index} {action}')
        ]);
    }
949124
public function onRender()
    {

        $meta = $this->dataStore->meta();
        $showColumnKeys = array();

        if ($this->columns == array()) {
            if ($row = $this->dataStore[0]) {
                $showColumnKeys = array_keys($row);
            } else if (count($meta["columns"]) > 0) {
                $showColumnKeys = array_keys($meta["columns"]);
            }
        } else {
            foreach ($this->columns as $cKey => $cValue) {

                if ($cKey === "{others}") {
                    $allKeys = array_keys($this->dataStore[0]);
                    foreach ($allKeys as $k) {
                        if (!in_array($k, $showColumnKeys)) {
                            $meta["columns"][$k] = array_merge($meta["columns"][$k], $cValue);
                            array_push($showColumnKeys, $k);
                        }
                    }
                } else {
                    if (gettype($cValue) == "array") {
                        if ($cKey === "#") {
                            $meta["columns"][$cKey] = array(
                                "type" => "number",
                                "label" => "#",
                                "start" => 1,
                            );
                        }

                        $meta["columns"][$cKey] = array_merge($meta["columns"][$cKey], $cValue);
                        if (!in_array($cKey, $showColumnKeys)) {
                            array_push($showColumnKeys, $cKey);
                        }
                    } else {
                        if ($cValue === "#") {
                            $meta["columns"][$cValue] = array(
                                "type" => "number",
                                "label" => "#",
                                "start" => 1,
                            );
                        }
                        if (!in_array($cValue, $showColumnKeys)) {
                            array_push($showColumnKeys, $cValue);
                        }
                    }

                }
            }
        }

        $cleanColumnKeys = array();
        foreach ($showColumnKeys as $key) {
            if (!in_array($key, $this->excludedColumns)) {
                array_push($cleanColumnKeys, $key);
            }
        }
        $showColumnKeys = $cleanColumnKeys;

        if (count($this->group) === 0 && count($this->sorting)>0) {
            $this->dataStore->sort($this->sorting);
        }

        //Prepare data
        $this->template(
            "Table",
            array(
                "showColumnKeys" => $showColumnKeys,
                "meta" => $meta,
            )
        );
    }
659522
static function init()
  {
    if (self::$initialized) return;

    self::$initialized = TRUE;

    self::$COFFEE_KEYWORDS  = array_merge(self::$COFFEE_KEYWORDS, array_keys(self::$COFFEE_ALIASES));
    self::$COFFEE_RESERVED  = array_merge(self::$JS_RESERVED, self::$JS_KEYWORDS, self::$COFFEE_KEYWORDS, self::$STRICT_PROSCRIBED);
    self::$JS_FORBIDDEN     = array_merge(self::$JS_KEYWORDS, self::$JS_RESERVED, self::$STRICT_PROSCRIBED);
    self::$INDEXABLE        = array_merge(self::$CALLABLE, self::$INDEXABLE);
    self::$NOT_SPACED_REGEX = array_merge(self::$NOT_REGEX, self::$NOT_SPACED_REGEX);

    Rewriter::init();

    self::$INVERSES         = Rewriter::$INVERSES;
  }
992092
public function getData()
    {
        $this->validate(
            'username',
            'password',
            'transactionId',
            'amount',
            'currency',
            'clientIp',
            'returnUrl',
            'cancelUrl',
            'notifyUrl',
            'clientMerchantId'
        );

        $document = new \DOMDocument('1.0', 'utf-8');
        $document->formatOutput = false;
        $document->createElement('soapenv:Header');

        $envelope = $document->appendChild(
            $document->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'soapenv:Envelope')
        );
        $envelope->setAttribute('xmlns:urn', 'urn:pscservice');

        $body = $envelope->appendChild(
            $document->createElement('soapenv:Body')
        );

        $disposition = $body->appendChild(
            $document->createElement('urn:createDisposition')
        );

        $disposition->appendChild(
            $document->createElement('urn:username', $this->getUsername())
        );

        $disposition->appendChild(
            $document->createElement('urn:password', $this->getPassword())
        );

        $disposition->appendChild(
            $document->createElement('urn:mtid', $this->getTransactionId())
        );

        $disposition->appendChild(
            $document->createElement('urn:subId', $this->getSubId())
        );

        $disposition->appendChild(
            $document->createElement('urn:amount', $this->getAmount())
        );

        $disposition->appendChild(
            $document->createElement('urn:currency', $this->getCurrency())
        );

        $disposition->appendChild(
            $document->createElement('urn:okUrl', rawurlencode($this->getReturnUrl()))
        );

        $disposition->appendChild(
            $document->createElement('urn:nokUrl', rawurlencode($this->getCancelUrl()))
        );

        $disposition->appendChild(
            $document->createElement('urn:pnUrl', rawurlencode($this->getNotifyUrl()))
        );

        $disposition->appendChild(
            $document->createElement('urn:shopId', $this->getShopId())
        );

        $disposition->appendChild(
            $document->createElement('urn:shopLabel', $this->getShopLabel())
        );

        $disposition->appendChild(
            $document->createElement('urn:merchantclientid', $this->getClientMerchantId())
        );

        if ($countryRestrictionValues = $this->getCountryRestrictions()) {
            $countryRestriction = $disposition->appendChild(
                $document->createElement('urn:dispositionRestrictions')
            );

            $countryRestriction->appendChild(
                $document->createElement('urn:key', 'COUNTRY')
            );

            $countryRestriction->appendChild(
                $document->createElement('urn:value', implode(',', $countryRestrictionValues))
            );
        }

        if ($minAgeRestrictionValue = $this->getMinAgeRestriction()) {
            $minAgeRestriction = $disposition->appendChild(
                $document->createElement('urn:dispositionRestrictions')
            );

            $minAgeRestriction->appendChild(
                $document->createElement('urn:key', 'MIN_AGE')
            );

            $minAgeRestriction->appendChild(
                $document->createElement('urn:value', $minAgeRestrictionValue)
            );
        }

        if ($minKycLevelRestrictionValue = $this->getMinKycLevelRestriction()) {
            $minKycLevelRestriction = $disposition->appendChild(
                $document->createElement('urn:dispositionRestrictions')
            );

            $minKycLevelRestriction->appendChild(
                $document->createElement('urn:key', 'MIN_KYC_LEVEL')
            );

            $minKycLevelRestriction->appendChild(
                $document->createElement('urn:value', $minKycLevelRestrictionValue)
            );
        }

        return $document->saveXML();
    }
236169
public function _afterLoad()
    {
        $value = $this->getValue();
        /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
        /** @noinspection PhpParamsInspection */
        $this->setValue(empty($value) ? false : $this->encoder->decode($value));
        parent::_afterLoad();
    }
917844
public function run()
	{
		$script = "jQuery('{$this->selector}').attr('data-spy', 'scroll');";

		if (isset($this->target)) {
			$script .= "jQuery('{$this->selector}').attr('data-target', '{$this->target}');";
		}

		if (isset($this->offset)) {
			$script .= "jQuery('{$this->selector}').attr('data-offset', '{$this->offset}');";
		}

		/** @var CClientScript $cs */
		$cs = Yii::app()->getClientScript();
		$cs->registerScript(__CLASS__ . '#' . $this->selector, $script, CClientScript::POS_BEGIN);

		foreach ($this->events as $name => $handler) {
			$handler = CJavaScript::encode($handler);
			$cs->registerScript(
				__CLASS__ . '#' . $this->selector . '_' . $name,
				"jQuery('{$this->selector}').on('{$name}', {$handler});"
			);
		}
	}
3113
public function execute($n)
    {
        $stack = array();
        $i = 0;
        $total = count($this->tokens);
        while ($i < $total) {
            $next = $this->tokens[$i];
            $i++;
            if ($next[0] === 'var') {
                $stack[] = $n;
                continue;
            } elseif ($next[0] === 'value') {
                $stack[] = $next[1];
                continue;
            }

            // Only operators left.
            switch ($next[1]) {
                case '%':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 % $v2;
                    break;

                case '||':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 || $v2;
                    break;

                case '&&':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 && $v2;
                    break;

                case '<':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 < $v2;
                    break;

                case '<=':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 <= $v2;
                    break;

                case '>':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 > $v2;
                    break;

                case '>=':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 >= $v2;
                    break;

                case '!=':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 != $v2;
                    break;

                case '==':
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 == $v2;
                    break;

                case '?:':
                    $v3 = array_pop($stack);
                    $v2 = array_pop($stack);
                    $v1 = array_pop($stack);
                    $stack[] = $v1 ? $v2 : $v3;
                    break;

                default:
                    throw new Exception(sprintf('Unknown operator "%s"', $next[1]));
            }
        }

        if (count($stack) !== 1) {
            throw new Exception('Too many values remaining on the stack');
        }

        return (int) $stack[0];
    }
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);
	}
776244
public function index()
    {
        //  If you're logged in you shouldn't be accessing this method
        if (isLoggedIn()) {
            redirect($this->data['return_to']);
        }

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

        //  If there's POST data attempt to log user in
        $oInput = Factory::service('Input');
        if ($oInput->post()) {

            //  Validate input
            $oFormValidation = Factory::service('FormValidation');

            //  The rules vary depending on what login methods are enabled.
            switch (APP_NATIVE_LOGIN_USING) {

                case 'EMAIL':
                    $oFormValidation->set_rules('identifier', 'Email', 'required|trim|valid_email');
                    break;

                case 'USERNAME':
                    $oFormValidation->set_rules('identifier', 'Username', 'required|trim');
                    break;

                default:
                    $oFormValidation->set_rules('identifier', 'Username or Email', 'trim');
                    break;
            }

            //  Password is always required, obviously.
            $oFormValidation->set_rules('password', 'Password', 'required');
            $oFormValidation->set_message('required', lang('fv_required'));
            $oFormValidation->set_message('valid_email', lang('fv_valid_email'));

            if ($oFormValidation->run()) {

                //  Attempt the log in
                $sIdentifier = $oInput->post('identifier');
                $sPassword   = $oInput->post('password');
                $bRememberMe = (bool) $oInput->post('remember');
                $oAuthModel  = Factory::model('Auth', 'nails/module-auth');

                $oUser = $oAuthModel->login($sIdentifier, $sPassword, $bRememberMe);

                if ($oUser) {
                    $this->_login($oUser, $bRememberMe);
                } else {
                    $this->data['error'] = $oAuthModel->lastError();
                }

            } else {
                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

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

        $oSocial                               = Factory::service('SocialSignOn', 'nails/module-auth');
        $this->data['social_signon_enabled']   = $oSocial->isEnabled();
        $this->data['social_signon_providers'] = $oSocial->getProviders('ENABLED');

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

        $this->loadStyles(NAILS_APP_PATH . 'application/modules/auth/views/login/form.php');

        Factory::service('View')
            ->load([
                'structure/header/blank',
                'auth/login/form',
                'structure/footer/blank',
            ]);
    }
555642
public function process()
    {
        parent::process();

        if (!$this->isVisible()) {
            return;
        }

        $hour = 0;
        $minute = 0;
        $second = 0;

        $all_empty = true;
        $any_empty = false;

        if ($this->display_parts & self::HOUR) {
            $hour_flydown = $this->getCompositeWidget('hour_flydown');
            $hour = $hour_flydown->value;
            if ($hour === null) {
                if ($this->required_parts & self::HOUR) {
                    $any_empty = true;
                } else {
                    $hour = 0;
                }
            } else {
                $all_empty = false;
            }

            if ($this->twelve_hour) {
                $am_pm_flydown = $this->getCompositeWidget('am_pm_flydown');
                $am_pm = $am_pm_flydown->value;
                if ($am_pm === null) {
                    if ($this->required_parts & self::HOUR) {
                        $any_empty = true;
                    } else {
                        $am_pm = 'am';
                    }
                } else {
                    $all_empty = false;
                }

                // convert 12-hour display to 24-hour value
                if ($hour !== null && $am_pm == 'pm' && $hour != 12) {
                    $hour += 12;
                }
                if ($hour == 12 && $am_pm == 'am') {
                    $hour = 0;
                }
            }
        }

        if ($this->display_parts & self::MINUTE) {
            $minute_flydown = $this->getCompositeWidget('minute_flydown');
            $minute = $minute_flydown->value;
            if ($minute === null) {
                if ($this->required_parts & self::MINUTE) {
                    $any_empty = true;
                } else {
                    $minute = 0;
                }
            } else {
                $all_empty = false;
            }
        }

        if ($this->display_parts & self::SECOND) {
            $second_flydown = $this->getCompositeWidget('second_flydown');
            $second = $second_flydown->value;
            if ($second === null) {
                if ($this->required_parts & self::SECOND) {
                    $any_empty = true;
                } else {
                    $second = 0;
                }
            } else {
                $all_empty = false;
            }
        }

        if ($all_empty) {
            if ($this->required && $this->isSensitive()) {
                if ($this->show_field_title_in_messages) {
                    $message = Swat::_('%s is required.');
                } else {
                    $message = Swat::_('This field is required.');
                }
                $this->addMessage(new SwatMessage($message, 'error'));
            }
            $this->value = null;
        } elseif ($any_empty) {
            if ($this->show_field_title_in_messages) {
                $message = Swat::_('%s is not a valid time.');
            } else {
                $message = Swat::_('This is not a valid time.');
            }
            $this->addMessage(new SwatMessage($message, 'error'));
            $this->value = null;
        } else {
            try {
                $date = new SwatDate();
                if (
                    $date->setDate(
                        self::$date_year,
                        self::$date_month,
                        self::$date_day
                    ) === false
                ) {
                    throw new SwatException('Invalid date.');
                }

                if ($date->setTime($hour, $minute, $second) === false) {
                    throw new SwatException('Invalid date.');
                }

                $date->setTZById('UTC');

                $this->value = $date;
                $this->validateRanges();
            } catch (SwatException $e) {
                if ($this->show_field_title_in_messages) {
                    $message = Swat::_('%s is not a valid time.');
                } else {
                    $message = Swat::_('This is not a valid time.');
                }
                $this->addMessage(new SwatMessage($message, 'error'));
                $this->value = null;
            }
        }
    }
1096390
public function showCommandList(): void
    {
        /** @var \Inhere\Console\IO\Input $input */
        $input = $this->input;
        // has option: --auto-completion
        $autoComp = $input->getBoolOpt('auto-completion');
        // has option: --shell-env
        $shellEnv = (string)$input->getLongOpt('shell-env', '');

        // php bin/app list --only-name
        if ($autoComp && $shellEnv === 'bash') {
            $this->dumpAutoCompletion($shellEnv, []);
            return;
        }

        /** @var \Inhere\Console\IO\Output $output */
        $output = $this->output;
        /** @var Router $router */
        $router = $this->getRouter();
        $script = $this->getScriptName();

        $hasGroup    = $hasCommand = false;
        $groupArr    = $commandArr = [];
        $placeholder = 'No description of the command';

        // all console groups/controllers
        if ($groups = $router->getControllers()) {
            $hasGroup = true;
            \ksort($groups);
        }

        // all independent commands, Independent, Single, Alone
        if ($commands = $router->getCommands()) {
            $hasCommand = true;
            \ksort($commands);
        }

        // add split title on both exists.
        if (!$autoComp && $hasCommand && $hasGroup) {
            $groupArr[]   = \PHP_EOL . '- <bold>Group Commands</bold>';
            $commandArr[] = \PHP_EOL . '- <bold>Alone Commands</bold>';
        }

        foreach ($groups as $name => $info) {
            $options    = $info['options'];
            $controller = $info['handler'];
            /** @var \Inhere\Console\AbstractHandler $controller */
            $desc    = $controller::getDescription() ?: $placeholder;
            $aliases = $options['aliases'];
            $extra   = $aliases ? ColorTag::wrap(
                ' [alias: ' . \implode(',', $aliases) . ']',
                'info'
            ) : '';

            // collect
            $groupArr[$name] = $desc . $extra;
        }

        if (!$hasGroup && $this->isDebug()) {
            $groupArr[] = '... Not register any group command(controller)';
        }

        foreach ($commands as $name => $info) {
            $desc    = $placeholder;
            $options = $info['options'];
            $command = $info['handler'];

            /** @var \Inhere\Console\AbstractHandler $command */
            if (\is_subclass_of($command, CommandInterface::class)) {
                $desc = $command::getDescription() ?: $placeholder;
            } elseif ($msg = $options['description'] ?? '') {
                $desc = $msg;
            } elseif (\is_string($command)) {
                $desc = 'A handler : ' . $command;
            } elseif (\is_object($command)) {
                $desc = 'A handler by ' . \get_class($command);
            }

            $aliases = $options['aliases'];
            $extra   = $aliases ? ColorTag::wrap(' [alias: ' . \implode(',', $aliases) . ']', 'info') : '';

            $commandArr[$name] = $desc . $extra;
        }

        if (!$hasCommand && $this->isDebug()) {
            $commandArr[] = '... Not register any alone command';
        }

        // built in commands
        $internalCommands = static::$internalCommands;

        if ($autoComp && $shellEnv === 'zsh') {
            $map = \array_merge($internalCommands, $groupArr, $commandArr);
            $this->dumpAutoCompletion('zsh', $map);
            return;
        }

        \ksort($internalCommands);
        Console::startBuffer();

        if ($appDesc = $this->getParam('description', '')) {
            $appVer = $this->getParam('version', '');
            Console::writeln(\sprintf('%s%s' . \PHP_EOL, $appDesc, $appVer ? " (Version: <info>$appVer</info>)" : ''));
        }

        // built in options
        $internalOptions = FormatUtil::alignOptions(self::$globalOptions);

        Show::mList([
            'Usage:'              => "$script <info>{command}</info> [--opt -v -h ...] [arg0 arg1 arg2=value2 ...]",
            'Options:'            => $internalOptions,
            'Internal Commands:'  => $internalCommands,
            'Available Commands:' => \array_merge($groupArr, $commandArr),
        ], [
            'sepChar' => '  ',
        ]);

        unset($groupArr, $commandArr, $internalCommands);
        Console::write("More command information, please use: <cyan>$script {command} -h</cyan>");
        Console::flushBuffer();
    }