public static function category_select($categories = null, $item = null, $default_item = null)
 {
     // Did user select a specific category to post in?
     $catId = Params::getParam('catId');
     if ($categories == null) {
         $categories = osc_get_categories();
     }
     if ($item == null) {
         $item = osc_item();
     }
     echo '<select name="catId" id="catId">';
     if (isset($default_item)) {
         echo '<option value="">' . $default_item . '</option>';
     } else {
         echo '<option value="">' . __('Select a category') . '</option>';
     }
     foreach ($categories as $c) {
         $selected = isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id'] || isset($catId) && $catId == $c['pk_i_id'];
         echo '<option value="' . $c['pk_i_id'] . '"' . ($selected ? 'selected="selected"' : '') . '>' . $c['s_name'] . '</option>';
         if (isset($c['categories']) && is_array($c['categories'])) {
             ItemForm::subcategory_select($c['categories'], $item, $default_item, 1);
         }
     }
     echo '</select>';
     return true;
 }
 function theme_install()
 {
     $categories = osc_get_categories();
     $categories_ids = array();
     addSubCategoories($categories, $categories_ids);
     if (!osc_get_preference('keyword_placeholder', 'seeker')) {
         osc_set_preference('keyword_placeholder', __('ie. PHP Programmer'), 'seeker');
     }
     if (!Field::newInstance()->findBySlug('s_department')) {
         Field::newInstance()->insertField(__('Department or Unit', 'seeker'), 'TEXT', 's_department', 0, '', $categories_ids);
     }
     if (!Field::newInstance()->findBySlug('s_position_type')) {
         Field::newInstance()->insertField(__('Employment Type', 'seeker'), 'DROPDOWN', 's_position_type', 0, __('Full Time', 'seeker') . ',' . __('Part Time', 'seeker') . ',' . __('Part Time to Full Time', 'seeker') . ',' . __('Temporary', 'seeker') . ',' . __('Temporary to Full Time', 'seeker') . ',' . __('Full Time', 'seeker') . ',' . __('Contracted', 'seeker') . ',' . __('Contracted to Full Time', 'seeker') . ',' . __('Internship', 'seeker') . ',' . __('Internship to Full Time', 'seeker') . ',' . __('Seasonal', 'seeker') . ',' . __('Volunteer', 'seeker'), $categories_ids);
     }
     if (!Field::newInstance()->findBySlug('s_job_experience')) {
         Field::newInstance()->insertField(__('Minimum Experience', 'seeker'), 'DROPDOWN', 's_job_experience', 0, __('Student (High School)', 'seeker') . ',' . __('Student (College)', 'seeker') . ',' . __('Entry Level', 'seeker') . ',' . __('Mid Level', 'seeker') . ',' . __('Experienced', 'seeker') . ',' . __('Manager/Supervisor', 'seeker') . ',' . __('Senior Manager/Supervisor', 'seeker') . ',' . __('Executive', 'seeker') . ',' . __('Senior Executive'), $categories_ids);
     }
     if (!Field::newInstance()->findBySlug('s_number_positions')) {
         Field::newInstance()->insertField(__('Number of positions', 'seeker'), 'TEXT', 's_number_positions', 0, '', $categories_ids);
     }
     if (!Field::newInstance()->findBySlug('s_salary')) {
         Field::newInstance()->insertField(__('Salary', 'seeker'), 'TEXT', 's_salary', 0, '', $categories_ids);
     }
     $version = theme_version_info();
     //Save that theme has installed
     osc_set_preference($version['name'], $version['version'], 'seeker');
 }
 public static function category_select($categories = null, $item = null, $default_item = null, $parent_selectable = false)
 {
     // Did user select a specific category to post in?
     $catId = Params::getParam('catId');
     if (Session::newInstance()->_getForm('catId') != "") {
         $catId = Session::newInstance()->_getForm('catId');
     }
     if ($categories == null) {
         if (View::newInstance()->_exists('categories')) {
             $categories = View::newInstance()->_get('categories');
         } else {
             $categories = osc_get_categories();
         }
     }
     if ($item == null) {
         $item = osc_item();
     }
     echo '<select name="catId" id="catId">';
     if (isset($default_item)) {
         echo '<option value="">' . $default_item . '</option>';
     } else {
         echo '<option value="">' . __('Select a category') . '</option>';
     }
     if (count($categories) == 1) {
         $parent_selectable = 1;
     }
     foreach ($categories as $c) {
         if (!osc_selectable_parent_categories() && !$parent_selectable) {
             echo '<optgroup label="' . $c['s_name'] . '">';
             if (isset($c['categories']) && is_array($c['categories'])) {
                 ItemForm::subcategory_select($c['categories'], $item, $default_item, 1);
             }
         } else {
             $selected = isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id'] || isset($catId) && $catId == $c['pk_i_id'];
             echo '<option value="' . $c['pk_i_id'] . '"' . ($selected ? 'selected="selected"' : '') . '>' . $c['s_name'] . '</option>';
             if (isset($c['categories']) && is_array($c['categories'])) {
                 ItemForm::subcategory_select($c['categories'], $item, $default_item, 1);
             }
         }
     }
     echo '</select>';
     return true;
 }
function item_category_select_js()
{
    ?>
        <script type="text/javascript">
            twitter_theme.categories = {} ;
        <?php 
    $aCategories = osc_get_categories();
    foreach ($aCategories as $category) {
        if (is_array($category['categories']) && count($category['categories']) > 0) {
            echo 'twitter_theme.categories.id_' . $category['pk_i_id'] . ' = {' . PHP_EOL;
            for ($i = 0; $i < count($category['categories']); $i++) {
                echo $category['categories'][$i]['pk_i_id'] . ': { id: ' . $category['categories'][$i]['pk_i_id'] . ', slug: "' . addslashes($category['categories'][$i]['s_slug']) . '", name: "' . addslashes($category['categories'][$i]['s_name']) . '"';
                if ($i == count($category['categories']) - 1) {
                    echo '}' . PHP_EOL;
                } else {
                    echo '} ,' . PHP_EOL;
                }
            }
            echo '} ;';
        } else {
            echo 'twitter_theme.categories.' . $category['s_slug'] . ' = { } ;' . PHP_EOL;
        }
    }
    ?>
        </script>
        <?php 
}
Exemple #5
0
function ExportXML()
{
    // XML
    $xml = new DomDocument('1.0', 'UTF-8');
    $root = $xml->createElement('Categories');
    $root = $xml->appendChild($root);
    $categories = NULL;
    if (View::newInstance()->_exists('categories')) {
        $categories = View::newInstance()->_get('categories');
    } else {
        $categories = osc_get_categories();
    }
    global $SubCategory_Array;
    foreach ($categories as $c) {
        $Category = $xml->createElement('Category');
        $Category = $root->appendChild($Category);
        $Name = $xml->createElement('Name', $c['s_name']);
        $Name = $Category->appendChild($Name);
        if (isset($c['categories']) && is_array($c['categories'])) {
            CreateCategory($c['categories'], $xml, $Category);
        }
    }
    $xml->formatOutput = true;
    $xml->saveXML();
    $xml->save('outCategory.xml');
    global $message;
    $message = "Successful Category export. '/oc-admin/outCategory.xml'";
}
    public static function category_two_selects($categories = null, $item = null, $default_item = null, $parent_selectable = false)
    {
        $categoryID = Params::getParam('catId');
        if (osc_item_category_id() != null) {
            $categoryID = osc_item_category_id();
        }
        if (Session::newInstance()->_getForm('catId') != '') {
            $categoryID = Session::newInstance()->_getForm('catId');
        }
        $subcategoryID = '';
        if (!Category::newInstance()->isRoot($categoryID)) {
            $subcategoryID = $categoryID;
            $category = Category::newInstance()->findRootCategory($categoryID);
            $categoryID = $category['pk_i_id'];
        }
        if ($categories == null) {
            if (View::newInstance()->_exists('categories')) {
                $categories = View::newInstance()->_get('categories');
            } else {
                $categories = osc_get_categories();
            }
        }
        if ($item == null) {
            $item = osc_item();
        }
        $subcategory = array();
        ?>
            <select id="parentCategory" name="parentCatId">
                <option value=""><?php 
        _e('Select Category');
        ?>
</option>
                <?php 
        foreach ($categories as $_category) {
            $selected = isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $_category['pk_i_id'] || isset($categoryID) && $categoryID == $_category['pk_i_id'];
            if ($selected) {
                $subcategory = $_category;
            }
            echo '<option value="' . $_category['pk_i_id'] . '" ' . ($selected ? 'selected="selected"' : '') . '>' . $_category['s_name'] . '</option>';
        }
        ?>
            </select>
            <select id="catId" name="catId">
                <?php 
        if (!empty($subcategory)) {
            if (count($subcategory['categories']) > 0) {
                echo '<option value="">' . __('Select Subcategory') . '</option>';
                foreach ($subcategory['categories'] as $c) {
                    $selected = isset($item["fk_i_category_id"]) && $item["fk_i_category_id"] == $c['pk_i_id'] || isset($subcategoryID) && $subcategoryID == $c['pk_i_id'];
                    echo '<option value="' . $c['pk_i_id'] . '" ' . ($selected ? 'selected="selected"' : '') . '>' . $c['s_name'] . '</option>';
                }
            } else {
                echo '<option value="' . $category['pk_i_id'] . '" >' . __('No Subcategory') . '</option>';
            }
        } else {
            echo '<option value="">' . __('Select Subcategory') . '</option>';
        }
        ?>
            </select>
            <script type="text/javascript" charset="utf-8">
                <?php 
        foreach ($categories as $c) {
            if (count($c['categories']) > 0) {
                $subcategory = array();
                for ($i = 0; $i < count($c['categories']); $i++) {
                    $subcategory[] = array($c['categories'][$i]['pk_i_id'], $c['categories'][$i]['s_name']);
                }
                printf('var categories_%1$s = %2$s;', $c['pk_i_id'], json_encode($subcategory));
                echo PHP_EOL;
            }
        }
        ?>

                if(osc==undefined) { var osc = {}; }
                if(osc.langs==undefined) { osc.langs = {}; }
                if(osc.langs.select_subcategory==undefined) { osc.langs.select_subcategory = '<?php 
        echo osc_esc_js(__('Select Subcategory'));
        ?>
'; }
                if(osc.langs.no_subcategory==undefined) { osc.langs.no_subcategory = '<?php 
        echo osc_esc_js(__('No Subcategory'));
        ?>
'; }

                $(document).ready(function(){
                    $("#parentCategory").bind('change', function(){
                        var categoryID = $(this).val();
                        if( categoryID == 0 ) {
                            var options = '<option value="' + categoryID + '" selected="">' + osc.langs.no_subcategory + '</option>';
                        }
                        categories = window['categories_' + categoryID];
                        if( categories==null || !$.isArray(categories) ) {
                            var options = '<option value="' + categoryID + '" >' + osc.langs.no_subcategory + '</option>';
                        } else {
                            var options = '<option value="' + categoryID + '" >' + osc.langs.select_subcategory + '</option>';
                            $.each(categories, function(index, value){
                                options += '<option value="' + value[0] + '">' + value[1] + '</option>';
                            });
                        };
                        $('#catId').html(options);
                        $("#catId").next("a").find(".select-box-label").text(osc.langs.select_subcategory);
                        $("#catId").change();
                    });

                });

            </script>
        <?php 
    }