Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • Markdown_Parser
  • MarkdownExtra_Parser
  • PasswordGetInfoTest
  • PasswordHashTest
  • PasswordNeedsRehashTest
  • PasswordVerifyTest
  • taxonomy_support_WdMarkups
  • Textile
  • Textmark_Parser
  • WdEMailNotifyElement

Functions

  • identify_modifier_markdown
  • Markdown
  • mdwp_add_p
  • mdwp_hide_tags
  • mdwp_MarkdownPost
  • mdwp_show_tags
  • mdwp_strip_p
  • password_get_info
  • password_hash
  • password_needs_rehash
  • password_verify
  • smarty_modifier_markdown
  • strip_comments
  • wd_spamScore
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 use ICanBoogie\Exception;
 13 use Icybee\Modules\Taxonomy\Terms\Term;
 14 
 15 class taxonomy_support_WdMarkups
 16 {
 17     static public function popularity(array $args, Patron\Engine $patron, $template)
 18     {
 19         extract($args, EXTR_PREFIX_ALL, 'p');
 20 
 21         $where = array();
 22         $params = array();
 23 
 24         #
 25         # vocabulary
 26         #
 27 
 28         if ($p_vocabulary)
 29         {
 30             $where[] = '(v.vocabulary = ? OR v.vocabularyslug = ?)';
 31             $params[] = $p_vocabulary;
 32             $params[] = $p_vocabulary;
 33         }
 34 
 35         #
 36         # scope of the vocabulary
 37         #
 38 
 39         if ($p_scope)
 40         {
 41             $parts = explode(',', $p_scope);
 42             $parts = array_map('trim', $parts);
 43 
 44             if (count($parts) > 1)
 45             {
 46                 $where[] = 'vs.constructor IN (' . implode(', ', array_pad(array(), count($parts), '?')) . ')';
 47                 $params = array_merge($params, $parts);
 48             }
 49             else
 50             {
 51                 $where[] = 'vs.constructor = ?';
 52                 $params[] = $p_scope;
 53             }
 54         }
 55 
 56         #
 57         # query
 58         #
 59 
 60         global $core;
 61 
 62         $entries = $core->db->query
 63         (
 64             'SELECT t.*,
 65 
 66             (SELECT COUNT(nid) FROM {prefix}taxonomy_terms__nodes tn WHERE tn.vtid = t.vtid) AS `used`
 67 
 68             FROM {prefix}taxonomy_vocabulary v
 69             INNER JOIN {prefix}taxonomy_vocabulary__scopes vs USING(vid)
 70             INNER JOIN {prefix}taxonomy_terms t USING(vid)
 71 
 72             ' . ($where ? 'WHERE ' . implode(' AND ', $where) : '') . '
 73 
 74             GROUP BY vtid ORDER BY term',
 75 
 76             $params
 77         )
 78         ->fetchAll(PDO::FETCH_ASSOC);
 79 
 80         #
 81         # remove used entries
 82         #
 83 
 84         foreach ($entries as $i => $entry)
 85         {
 86             if ($entry['used'])
 87             {
 88                 continue;
 89             }
 90 
 91             unset($entries[$i]);
 92         }
 93 
 94         #
 95         # scale popularities
 96         #
 97 
 98         if ($p_scale)
 99         {
100             $min = 0xFFFFFFFF;
101             $max = 0;
102 
103             foreach ($entries as $entry)
104             {
105                 $min = min($min, $entry['used']);
106                 $max = max($max, $entry['used']);
107             }
108 
109             $range = max($max - $min, 1);
110 
111             //echo "min: $min, max: $max, range: $range<br />";
112 
113             foreach ($entries as &$entry)
114             {
115                 $entry['popularity'] = 1 + round(($entry['used'] - $min) / $range * ($p_scale - 1));
116             }
117         }
118 
119         return $patron($template, $entries);
120     }
121 }
Autodoc API documentation generated by ApiGen 2.8.0