Ejemplo n.º 1
0
 /**
  * Looks up the list of options from the DB
  * This is the only place where themes are 'categorized', which is purely for presentation in the walk create form
  *
  * @param string $type Which type of tag to return (e.g. theme, accessible)
  * @return array
  */
 public static function getSelectOptions($type = 'all')
 {
     $options = array();
     $satc = new SelectAttributeTypeController(AttributeType::getByHandle('select'));
     if ($type === 'all' || $type === 'theme') {
         $satc->setAttributeKey(CollectionAttributeKey::getByHandle('theme'));
         $themeAK = CollectionAttributeKey::getByHandle('theme');
         foreach ($satc->getOptions() as $v) {
             $category = $this->getCategory($v->value);
             $options['theme'][$category][] = ['handle' => $v->value, 'name' => self::getName($v->value)];
         }
     }
     if ($type === 'all' || $type === 'accessibile') {
         $satc->setAttributeKey(CollectionAttributeKey::getByHandle('accessible'));
         foreach ($satc->getOptions() as $v) {
             $options['accessible'][] = ['handle' => $v->value, 'name' => self::getName($v->value)];
         }
     }
     return $options;
 }
if (count($row['displayAttributes']) > 0) {
    Loader::model('attribute/categories/collection');
    $satc = new SelectAttributeTypeController(AttributeType::getByHandle('select'));
    // Get existing query string to pass through filtering parameters
    $request = $_SERVER['REQUEST_URI'];
    $url_parts = parse_url($request);
    $url_params = array();
    parse_str($url_parts['query'], $url_params);
    $query_string = http_build_query($url_params);
    // Display select attributes (and their options) specified in ajax_page_list.php as lists of links
    echo '<div class="page-list-filters">';
    echo '<p><strong>' . t('Filter by:') . '</strong></p>';
    foreach ($row['displayAttributes'] as $attribute_handle) {
        $ak = CollectionAttributeKey::getByHandle($attribute_handle);
        $satc->setAttributeKey($ak);
        $options = $satc->getOptions();
        if (count($options) > 0) {
            echo '<div class="page-list-filter">';
            echo $ak->getAttributeKeyName();
            echo '<ul>';
            foreach ($options as $opt) {
                $class = '';
                // Create parameters for attribute links to be toggled,
                // and apply 'active' class to active filters
                if ($row['filterAttributes'][$attribute_handle] == $opt) {
                    $class = 'active';
                    $additional_params = '&filterAttributes[' . $attribute_handle . ']=';
                } else {
                    $additional_params = '&filterAttributes[' . $attribute_handle . ']=' . $opt;
                }
                echo '<li><a href="javascript:;" class="' . $class . '" data-href="' . $url_parts['path'] . '?' . $query_string . $additional_params . '">' . $opt . '</a></li>';