## --------------------------------------------------------
174813
private function findSharp($orig, $final)
		# Author:     Ryan Rud (http://adryrun.com)
		# Purpose:    Find optimal sharpness
		# Param in:   n/a
		# Param out:  n/a
		# Reference:
		# Notes:
		#
	{
		$final = $final * (750.0 / $orig);
		$a = 52;
		$b = -0.27810650887573124;
		$c = .00047337278106508946;

		$result = $a + $b * $final + $c * $final * $final;

		return max(round($result), 0);
	}
845733
public function indexAction()
    {
        $user = $this->userService->getCurrentUser();
        $workspacesArray = [];
        /** @var Workspace $workspace */
        foreach ($this->workspaceRepository->findAll() as $workspace) {

            // FIXME: This check should be implemented through a specialized Workspace Privilege or something similar
            if ($workspace->getOwner() !== null && $workspace->getOwner() !== $user) {
                continue;
            }

            $workspaceArray = [
                'name' => $workspace->getName(),
                'title' => $workspace->getTitle(),
                'description' => $workspace->getDescription(),
                'baseWorkspace' => $workspace->getBaseWorkspace()
            ];
            if ($user !== null) {
                $workspaceArray['readonly'] = !$this->userService->currentUserCanPublishToWorkspace($workspace);
            }
            $workspacesArray[] = $workspaceArray;
        }

        $this->view->assign('workspaces', $workspacesArray);
    }
869816
public function init()
    {
        $this->filter = isset($_REQUEST['filter']) ? $_REQUEST['filter'] : [];
        $this->sort   = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : [];
    }
648419
public function run()
	{
		if(!empty($this->links)) {
		
			$links=array();
	
			foreach($this->links as $label=>$url) {
				if(is_string($label) || is_array($url))
					$links[] = CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url, array('title'=>$label));
				//else
				//	$links[] = '<span>'.($this->encodeLabel ? CHtml::encode($url) : $url).'</span>';
			}
		}
		
		/*
		if($this->homeLink===null)
			$links[]=CHtml::link(Yii::t('phrase', 'Close'), 'javascript:void(0);', array('title'=>Yii::t('phrase', 'Close'), 'class'=>'closed','off_address'=>''));
		elseif($this->homeLink!==false)
			$links[]=$this->homeLink;
		*/
		
		if(!empty($this->links)) {
			echo implode($this->separator,$links);
			echo ' '.Yii::t('phrase', 'or').' ';
		}
		echo CHtml::link(Yii::t('phrase', 'Close'), 'javascript:void(0);', array('title'=>Yii::t('phrase', 'Close'), 'class'=>'closed','off_address'=>''));
	}
163931
public function initialize()
    {
        parent::initialize();
        $this->select = new SelectClause($this);
        $this->from   = new FromClause($this);
        $this->group  = new GroupClause($this);
    }
564148
public function run() {
		
		$id = $this->htmlOptions['id'];

		echo CHtml::openTag('div', $this->htmlOptions);

		foreach ($this->alerts as $type => $alert) {

			if (is_string($alert)) {
				$type = $alert;
				$alert = array();
			}

			if (isset($alert['visible']) && $alert['visible'] === false) {
				continue;
			}

			/** @var CWebUser $userComponent */
			$userComponent = Yii::app()->getComponent($this->userComponentId);
			if (!$userComponent->hasFlash($type))
				continue;

			$alertText = $userComponent->getFlash($type);
            if (empty($alertText)) { // null, ''
                continue;
            }

			$this->renderSingleAlert($alert, $type, $alertText);
		}

		echo CHtml::closeTag('div');

		$id .= '_' . self::$_containerId++;
		$selector = "#{$id} .alert";

		/** @var CClientScript $cs */
		$cs = Yii::app()->getClientScript();
		$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('{$selector}').alert();");

		foreach ($this->events as $name => $handler) {
			$handler = CJavaScript::encode($handler);
			$cs->registerScript(
				__CLASS__ . '#' . $id . '_' . $name,
				"jQuery('{$selector}').on('{$name}', {$handler});"
			);
		}
	}
143692
public function generate(): string
    {
        $condID = (string)$this->attributes['data-conditional-id'];
        $getState = $this->vHandler->get->get($condID.'_state', Variables::TYPE_INT) == 1;
        $postState = $this->vHandler->post->get($condID.'_state', Variables::TYPE_INT) == 1;
        $visible = $getState || $postState;
        $this->attributes['class'] .= $visible === true ? ' visible' : '';

        $elements = [];
        $elements[] = Controlls\Text::inputHidden($condID.'_state', (int)$visible, ['method-get' => true, 'id' => '']);
        foreach ($this->elements as $element) {
            /** @noinspection PhpUndefinedMethodInspection */
            $elements[] = $element->generate();
        }
        return Tags::div($elements, $this->attributes);
    }
132156
public function initialize()
    {
        if ($this->initialized === false) {
            $this->data = $this->cursor->toArray();
        }
        $this->initialized = true;
    }
548898
public function int($value)
    {
        if ($this->notBeEmpty($value)) {
            if (is_int($value)) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
905450
public static function ColumnGroup()
	{
		$code	= "";
		$cols	= array();
		$args	= func_get_args( );
		if( is_array( $args[0] ) )
			$args	= $args[0];
		if( preg_match( "@,@", $args[0] ) )
			$args	= explode( ",", $args[0] );
		if( sizeof( $args ) )
		{
			foreach( $args as $arg )
				$cols[] = "<col width=\"".$arg."\"/>";
			$cols	= implode( "", $cols );
			$code	= "<colgroup>".$cols."</colgroup>";
		}
		return $code;	
	}
291012
public function run()
	{
		list($name,$id)=$this->resolveNameID();
		if(isset($this->htmlOptions['id']))
			$id=$this->htmlOptions['id'];
		else
			$this->htmlOptions['id']=$id;

		$isRange=isset($this->options['range']) && $this->options['range'] &&
			$this->options['range']!=='max' && $this->options['range']!=='min';

		if($this->hasModel())
		{
			$attribute=$this->attribute;
			if($isRange)
			{
				$options=$this->htmlOptions;
				echo CHtml::activeHiddenField($this->model,$this->attribute,$options);
				$options['id'].=$this->maxIdSuffix;
				echo CHtml::activeHiddenField($this->model,$this->maxAttribute,$options);
				$maxAttribute=$this->maxAttribute;
				$this->options['values']=array($this->model->$attribute,$this->model->$maxAttribute);
			}
			else
			{
				echo CHtml::activeHiddenField($this->model,$this->attribute,$this->htmlOptions);
				$this->options['value']=$this->model->$attribute;
			}
		}
		else
		{
			if($isRange)
			{
				list($maxName,$maxId)=$this->resolveNameID('maxName','maxAttribute');
				$options=$this->htmlOptions;
				echo CHtml::hiddenField($name,$this->value,$options);
				$options['id'].=$this->maxIdSuffix;
				echo CHtml::hiddenField($maxName,$this->maxValue,$options);
				$this->options['values']=array($this->value,$this->maxValue);
			}
			else
			{
				echo CHtml::hiddenField($name,$this->value,$this->htmlOptions);
				if($this->value!==null)
					$this->options['value']=$this->value;
			}
		}

		$idHidden=$this->htmlOptions['id'];
		$this->htmlOptions['id']=$idHidden.'_slider';
		echo CHtml::tag($this->tagName,$this->htmlOptions,'');

		$this->options[$this->event]=$isRange
			? new CJavaScriptExpression("function(e,ui){ v=ui.values; jQuery('#{$idHidden}').val(v[0]); jQuery('#{$idHidden}{$this->maxIdSuffix}').val(v[1]); }")
			: new CJavaScriptExpression("function(event, ui) { jQuery('#{$idHidden}').val(ui.value); }");

		$options=CJavaScript::encode($this->options);
		Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}_slider').slider($options);");
	}
257695
public function index()
    {











$article = Article::load()->findOrFail(1);
echo '<pre>'; print_r($article );

$article = Article::load()->find(1);
echo '<pre>'; print_r($article );





// Récupérer un article WHERE slug
$article = Article::load()->where('slug', '=', 'article-1')->find();
// Résultat SQL : "SELECT * FROM articles WHERE slug = 'article-1' LIMIT 1"


$article->testQuery();

// Récupérer un article WHERE slug ou une erreur HTTP 404
$article = Article::load()->where('slug', '=', 'article-1')->findOrFail();
// Résultat SQL : "SELECT * FROM articles WHERE slug = 'article-1' LIMIT 1"



// Récupérer un article WHERE slug
$article = Article::load()->findBySlug('article-1');
// Résultat SQL : "SELECT * FROM articles WHERE slug = 'article-1' LIMIT 1"

// Récupérer un article WHERE slug ou une erreur HTTP 404
$article = Article::load()->findOrFailBySlug('article-1');
// Résultat SQL : "SELECT * FROM articles WHERE slug = 'article-1' LIMIT 1"



// Récupérer une collection d'articles avec un WHERE
$articles = Article::load()->where('status', '=', 1)->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1"



// Récupérer une collection d'articles avec un WHERE
$articles = Article::load()->findAllByStatus(1);
// Résultat SQL : "SELECT * FROM articles WHERE status = 1"



$articles = Article::load()->where('status', '=', 1)->where('status', '=', 2)->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1 AND online = 1"



$articles = Article::load()->where('status', '=', 1)->orWhere('status', '=', 2)->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1 OR online = 1"




$articles = Article::load()->whereIn('id', [1, 2, 3])->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE id IN (1, 2, 3)"



$articles = Article::load()->whereIn('id', [1, 2, 3])->orWhereIn('id', [7, 8, 9])->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE id IN (1, 2, 3) OR id IN (20, 21, 22)"


$articles = Article::load()->where('status', '=', 1)->orderBy('title', 'ASC')->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1 ORDER BY 'title' ASC"



$articles = Article::load()->where('status', '=', 1)->limit(5)->offset(2)->findAll();
// Résultat SQL : "SELECT * FROM articles WHERE status = 1 LIMIT 5 OFFSET 2"




$article = new Article();

$articles = $article->paginate();
// Résultats SQL :
// SELECT COUNT(id) AS nb FROM articles WHERE status = 1
// Et :
// SELECT * FROM articles WHERE status = 1 LIMIT 10 OFFSET ? 

echo '<pre>'; print_r($article->getTotal());  // return int - Nombre d'articles paginés

$pagination = $article->getPagination();

foreach ($articles as $article) {
    echo $article->title;
}

echo $pagination->render();  // return string
echo $pagination->perPage();  // return string




$article = new Article();

$articles = $article->paginate(5);





// Par exemple, récupérer tous les articles qui sont joints à une catégorie WHERE son id avec un INNER JOIN
$articlesJoinedToCategory = Article::load()
    ->join(
        ArticleCategory::getTableIntermediateJoinedArticles(),
        Article::getTable().'.id', '=', ArticleCategory::getTableIntermediateJoinedArticles().'.article_id'
    )
    ->where(ArticleCategory::getTableIntermediateJoinedArticles().'.category_id', '=', 2)
    ->findAll();
// Résultat SQL :
// "SELECT * FROM articles
// INNER JOIN articles_categories_intermediate 
//   ON articles.id = articles_categories_intermediate.article_id
// WHERE articles_categories_intermediate.category_id = 2"
echo '<pre>'; print_r($articlesJoinedToCategory);


echo '<hr>';

// Par exemple, récupérer tout les articles qui sont joints à une catégorie WHERE son id avec un LEFT JOIN
$articlesJoinedToCategory = Article::load()
    ->leftJoin(
        ArticleCategory::getTableIntermediateJoinedArticles(),
        Article::getTable().'.id', '=', ArticleCategory::getTableIntermediateJoinedArticles().'.article_id'
    )
    ->where(ArticleCategory::getTableIntermediateJoinedArticles().'.category_id', '=', 2)
    ->findAll();
// Résultat SQL :
// "SELECT * FROM articles
// LEFT JOIN articles_categories_intermediate 
//   ON articles.id = articles_categories_intermediate.article_id
// WHERE articles_categories_intermediate.category_id = 2"
echo '<pre>'; print_r($articlesJoinedToCategory);

echo '<hr>';

// Par exemple, récupérer tout les articles qui sont joints à une catégorie WHERE son id avec un RIGHT JOIN
$articlesJoinedToCategory = Article::load()
    ->rightJoin(
        ArticleCategory::getTableIntermediateJoinedArticles(),
        Article::getTable().'.id', '=', ArticleCategory::getTableIntermediateJoinedArticles().'.article_id'
    )
    ->where(ArticleCategory::getTableIntermediateJoinedArticles().'.category_id', '=', 2)
    ->findAll();
// Résultat SQL :
// "SELECT * FROM articles
// RIGHT JOIN articles_categories_intermediate 
//   ON articles.id = articles_categories_intermediate.article_id
// WHERE articles_categories_intermediate.category_id = 2"
echo '<pre>'; print_r($articlesJoinedToCategory);




Article::load()->select('title, description, content')->where('id', '=', 1)->find();

Article::load()->select('title', 'description', 'content')->where('id', '=', 1)->find();

Article::load()->select(['title', 'description', 'content'])->where('id', '=', 1)->find();




$countArticles = Article::load()->count('id');
// return int - Résultat SQL : "SELECT COUNT(id) AS nb FROM articles"
// PS : Le paramètres 'id' n'est pas obligatoire. Est '*' par défaut.
echo '<pre>'; print_r($countArticles);


$countArticlesByStatus =  Article::load()->countByStatus(1);
// return int - Résultat SQL : "SELECT COUNT(*) AS nb FROM articles WHERE status = 1"
// PS : En 2ème paramètres de "countByStatus" on peut préciser la colonne en ajoutant un 2ème paramètres. Est '*' par défaut.




$sumIdArticles = Article::load()->sum('id');
// return int - Résultat SQL : "SELECT SUM(id) AS sum FROM articles"
echo '<pre>'; print_r($sumIdArticles);




$maxIdArticles = Article::load()->max('id');
// return int - Résultat SQL : "SELECT MAX(id) AS max FROM articles"
echo '<pre>'; print_r($maxIdArticles);




$condition = true;
$articles = Article::load()
    ->select('title, description, content')
    ->where('id', '!=', 1)
    ->when($condition === true, function ($query) {
        return $query->where('status', '=', 1);
    })
    ->findAll();
// Si $condition = true - Résultat SQL : "SELECT title, description, content FROM articles WHERE id != 1 AND status = 1"
// Si $condition = false - Résultat SQL : "SELECT title, description, content FROM articles WHERE id != 1"






$article = new Article();
$articles = $article->runRowCount(true)->findAll();
echo '<pre>'; print_r($article->getRowCount());
// return int - Nombre de lignes affectées



/*

$article = new Article();
$article->setStatus(2);
$article->setH1('Article 18');
$article->setDescription('Description Article 18');
$article->setContent('Content Article 18');
$article->setTitle('Title Article 18');
$article->setSlug('article-120');
$article->setUserId(2);
$article->save();


echo $article->getLastInsertId();
die;

Article::load()->create([
    'status' => 2,
    'h1' => 'Article 12',
    'description' => 'Description Article 12',
    'content' => 'Content Article 12',
    'title' => 'Title Article 12',
    'user_id' => 1,
    'slug' => 'article-12',
]);
// Résultat SQL :
// "INSERT INTO articles (status, h1, description, content, title, slug)
//  VALUES (1, 'Article 12', 'Description Article 12', 'Content Article 12', 'Title Article 12', 'article-12')"

*/








$article = Article::load()->findById(1);
$article->setStatus(2);
$article->setH1('Article 1');
$article->setDescription('Description Article 1');
$article->setContent('Content Article 1');
$article->setTitle('Title Article 1');
$article->setSlug('article-1');
$article->save();



echo $article->getNow();



Article::load()
    ->where('id', '=', 1)
    ->limit(1)
    ->update([
        'status' => 2,
        'h1' => 'Article 1',
        'description' => 'Description Article 1',
        'content' => 'Content Article 1',
        'title' => 'Title Article 1',
        'slug' => 'article-1',
    ]);



$_POST = [
    'status' => 2,
    'h1' => 'Article 1',
    'description' =>
    'Description Article 1',
    'content' => 'Content Article 1',
    'title' => 'Title Article 1',
    'slug' => 'article-1',
];

$article = Article::load()->findById(1);
$article->fill($_POST);
$article->save();

$_POST = [];


// Résultat SQL :
// "UPDATE articles SET
//  status = 1, h1 = 'Article 1', description = 'Description Article 1', content = 'Content Article 1', title = 'Title Article 1', slug = 'article-1'
//  WHERE id = 1 LIMIT 1"




$_POST = [
    'status' => 2,
    'h1' => 'Article 1',
    'description' =>
    'Description Article 1',
    'content' => 'Content Article 1',
    'title' => 'Title Article 1',
    'slug' => 'article-1',
];

$article = Article::load()->findById(1);

var_dump( $article->getTitle() );

$article->fill($_POST);

var_dump( $article->getTitle() );

$article->save();

var_dump( $article->getTitle() );

$_POST = [];












/*
$article = Article::load()->findById(18);
$article->delete();
// Résultats SQL :
// "SELECT * FROM articles WHERE id = 13 LIMIT 1"
// Et :
// "DELETE FROM articles WHERE id = 13 LIMIT 1"


Article::load()->where('id', '=', 17)->limit(1)->delete();

*/





$article = Article::load()->findById(1);
echo '<pre>'; print_r($article->getH1());





$article = new Article();

/*
try {
    // Démarrer une transaction
    $article->beginTransaction();

    // Valider une transaction
    $article->validTransaction();
} catch (\Exception $e) {
    // Annuler une transaction
    $article->cancelTransaction();
}
*/



echo '<hr>';




// Récupérer l'article WHERE son id :
$article = Article::load()->findById(1);
// Résultat SQL : "SELECT * FROM articles WHERE id = 1 LIMIT 1"

// Prenons pour exemple que la colonne 'user_id' de l'article a pour valeur "2"
// Récupérer l'user relié à cette article :
$userJoinedTiArticle = $article->user();
echo '<pre>'; print_r($userJoinedTiArticle);
// Résultat SQL : SELECT users.* FROM users WHERE users.id = 2 LIMIT 1



echo '<hr>';




$user = User::load()->findById(1);
// Résultat SQL : "SELECT * FROM users WHERE id = 1 LIMIT 1"

// Récupérer tous les articles reliés à cette user
$articlesJoinedToUser = $user->articles();
echo '<pre>'; print_r($articlesJoinedToUser);




echo '<hr>';






// Récupérer l'article WHERE son id :
$article = Article::load()->findById(1);
// Résultat SQL : "SELECT * FROM articles WHERE id = ? LIMIT 1"

// Récupérer toute les catégories jointes à cette article :
$articleCategories = $article->articleCategories();
echo '<pre>'; print_r($articleCategories);
// Résultat SQL :
// SELECT articles_categories.* FROM articles_categories
// INNER JOIN articles_categories_intermediate
//   ON articles_categories.id = articles_categories_intermediate.category_id
// WHERE articles_categories_intermediate.article_id = 2



$a = new Article;
$a->testQuery();




$article = new Article();
echo '<pre>'; print_r($article->getDbTable());




$article = new Article();
echo '<pre>'; print_r($article->getTable());





        return $this->view('article/index', [
            'baliseTitle' => 'Article listing title',
            'metaDescription' => 'Article listing desciption',
        ]);  
    }
859111
private static function init() {
        self::$huffmanLookup = self::huffmanLookupInit();
        self::$huffmanCodes = self::huffmanCodesInit();
        self::$huffmanLengths = self::huffmanLengthsInit();

        foreach (\array_column(self::TABLE, 0) as $index => $name) {
            if (isset(self::$indexMap[$name])) {
                continue;
            }

            self::$indexMap[$name] = $index + 1;
        }
    }
88292
public function moveRight() //#777C
    {
        $sArticleId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('aid');
        if ($sArticleId && ($aItems = $this->getCompareItems())) {
            $sNextArticleId = 0;

            $blFound = false;
            foreach ($aItems as $sOxid => $sVal) {
                if ($blFound) {
                    $sNextArticleId = $sOxid;
                    $blFound = false;
                }
                if ($sOxid == $sArticleId) {
                    $blFound = true;
                }
            }

            if ($sNextArticleId) {
                $aNewItems = [];
                foreach ($aItems as $sOxid => $sVal) {
                    if ($sOxid == $sArticleId) {
                        $aNewItems[$sNextArticleId] = true;
                    } elseif ($sOxid == $sNextArticleId) {
                        $aNewItems[$sArticleId] = true;
                    } else {
                        $aNewItems[$sOxid] = true;
                    }
                }
                $this->setCompareItems($aNewItems);
            }
        }
    }
835651
public function count() {
		if ($this->count === null) {
			$groupPart = $this->select->getPart(Select::GROUP);
			
			$select = empty($groupPart)
				? $this->prepareSelect(clone $this->select)
				: $this->prepareSubquerySelect(clone $this->select);
			
			$this->count = (int) $select->query(PDO::FETCH_OBJ)->fetch()->{self::COUNT_COLUMN};
		}
		
		return $this->count;
	}
134784
public function group($group){
        if(is_array($group)){
            $this->group= 'GROUP BY ';
            foreach ($group as $value) {
                $this->group .= $value.',';
            }
            $this->group= rtrim($this->group, ',');
            $this->group.=' ';
        }else{
            $this->group= 'GROUP BY '.$group.' ';
        }
    }
895154
public function index()
    {
        $this->data['page']->title = 'Manage Blogs';

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

        //  Get blogs
        $this->data['blogs'] = $this->blog_model->getAll();

        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.';

                $this->session->set_flashdata($status, $message);

                redirect('admin/blog/blog/create');

            }
        }

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

        //  Add a header button
        if (userHasPermission('admin:blog:blog:create')) {

             Helper::addHeaderButton('admin/blog/blog/create', 'Create Blog');
        }

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

        //  Load views
        Helper::loadView('index');
    }