Пример #1
0
    function resourceAccess($id, $access = array(), $varname = 'access', $text = null, $without_period = false)
    {
        if (!$text) {
            $text = __('Choose Products and/or Product Categories that allows access', 'am4-plugin');
        }
        $uniqid = uniqid('amw-');
        ?>
                
                <div class="resourceaccess <?php 
        echo $uniqid;
        ?>
" id="<?php 
        echo $id;
        ?>
" data-varname='<?php 
        echo $varname;
        ?>
'><?php 
        _e($text);
        ?>
<br/>
                                <input type='hidden' class='resourceaccess-init' value='<?php 
        if ($access) {
            $this->e(aMemberJson::init($this->addProductTitle($access)));
        } else {
            print '{}';
        }
        ?>
' />
                                <select class='category' size=1>
                                    <option value='' ><?php 
        _e('Please select an item...', 'am4-plugin');
        ?>
</option>
                                    <optgroup class='category' label='<?php 
        _e('Product Categories', 'am4-plugin');
        ?>
'>
                                    <option value='-1' style='font-weight: bold'><?php 
        _e('Any Product', 'am4-plugin');
        ?>
</option>
                                        <?php 
        $this->options(am4PluginsManager::getAMCategories());
        ?>
                                    </optgroup>
                                    <optgroup class='product' label='<?php 
        _e('Products', 'am4-plugin');
        ?>
'>
                                        <?php 
        $this->options(am4PluginsManager::getAMProducts());
        ?>
                                    </optgroup>
                                </select>
                            <div class='category-list'></div>
                            <div class='product-list'></div>
                            <br />                        
                </div>        
                <script type="text/javascript">
                    jQuery(document).ready(function ($){
                        jQuery('.<?php 
        echo $uniqid;
        ?>
').resourceAccess({without_period: <?php 
        echo $without_period ? 'true' : 'false';
        ?>
});
                    });
                </script>
                <?php 
    }
Пример #2
0
 function doAjaxBrowse()
 {
     $dirOrig = am4Request::get('dir', ABSPATH);
     $dirOrig = is_dir($dirOrig) ? $dirOrig : ABSPATH;
     $selected = am4Request::get('selected', false);
     $dir = $selected ? dirname($dirOrig) : $dirOrig;
     $dir = realpath($dir);
     if (!is_dir($dir)) {
         $dir = ABSPATH;
     }
     $dirList = $this->getDirList($dir);
     if ($selected) {
         foreach ($dirList as $k => $dirDescription) {
             if ($dirDescription['path'] == $dirOrig) {
                 $dirList[$k]['selected'] = true;
                 break;
             }
         }
     }
     $currentDir = $this->getCurrentDir($dir);
     $prevDir = $this->getPrevDir($dir);
     $result = array('dirList' => $dirList, 'currentDir' => $currentDir, 'prevDir' => $prevDir, 'separator' => DIRECTORY_SEPARATOR);
     aMemberJson::init($result)->send();
 }