当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::newInstance方法代码示例

本文整理汇总了PHP中Category::newInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::newInstance方法的具体用法?PHP Category::newInstance怎么用?PHP Category::newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category::newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_cat_stats

function update_cat_stats()
{
    $categoryTotal = array();
    $categoryTree = array();
    $aCategories = Category::newInstance()->listAll(false);
    // append root categories and get the number of items of each category
    foreach ($aCategories as $category) {
        $total = Item::newInstance()->numItems($category, true, true);
        $category += array('category' => array());
        if (is_null($category['fk_i_parent_id'])) {
            $categoryTree += array($category['pk_i_id'] => $category);
        }
        $categoryTotal += array($category['pk_i_id'] => $total);
    }
    // append childs to root categories
    foreach ($aCategories as $category) {
        if (!is_null($category['fk_i_parent_id'])) {
            $categoryTree[$category['fk_i_parent_id']]['category'][] = $category;
        }
    }
    // sum the result of the subcategories and set in the parent category
    foreach ($categoryTree as $category) {
        if (count($category['category']) > 0) {
            foreach ($category['category'] as $subcategory) {
                $categoryTotal[$category['pk_i_id']] += $categoryTotal[$subcategory['pk_i_id']];
            }
        }
    }
    foreach ($categoryTotal as $k => $v) {
        CategoryStats::newInstance()->setNumItems($k, $v);
    }
}
开发者ID:acharei,项目名称:OSClass,代码行数:32,代码来源:cron.hourly.php

示例2: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'logout':
             // unset only the required parameters in Session
             Session::newInstance()->_drop('adminId');
             Session::newInstance()->_drop('adminUserName');
             Session::newInstance()->_drop('adminName');
             Session::newInstance()->_drop('adminEmail');
             Session::newInstance()->_drop('adminLocale');
             Cookie::newInstance()->pop('oc_adminId');
             Cookie::newInstance()->pop('oc_adminSecret');
             Cookie::newInstance()->pop('oc_adminLocale');
             Cookie::newInstance()->set();
             $this->redirectTo(osc_admin_base_url(true));
             break;
         default:
             //default dashboard page (main page at oc-admin)
             $this->_exportVariableToView("numUsers", User::newInstance()->count());
             $this->_exportVariableToView("numAdmins", Admin::newInstance()->count());
             $this->_exportVariableToView("numItems", Item::newInstance()->count());
             $this->_exportVariableToView("numItemsPerCategory", CategoryStats::newInstance()->toNumItemsMap());
             $this->_exportVariableToView("categories", Category::newInstance()->listAll());
             $this->_exportVariableToView("newsList", osc_listNews());
             $this->_exportVariableToView("comments", ItemComment::newInstance()->getLastComments(5));
             //calling the view...
             $this->doView('main/index.php');
     }
 }
开发者ID:hashemgamal,项目名称:OSClass,代码行数:29,代码来源:main.php

示例3: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'add_post':
             if (Params::getParam('field_name') != '') {
                 $field = $this->fieldManager->findByName(Params::getParam('field_name'));
                 if (!isset($field['pk_i_id'])) {
                     $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower(Params::getParam("field_slug"))));
                     $this->fieldManager->insertField(Params::getParam("field_name"), Params::getParam("field_type_new"), $slug, Params::getParam("field_required") == "1" ? 1 : 0, Params::getParam('field_options'), Params::getParam('categories'));
                     osc_add_flash_ok_message(_m("New custom field added"), "admin");
                 } else {
                     osc_add_flash_error_message(_m("Sorry, you already have one field with that name"), "admin");
                 }
             } else {
                 osc_add_flash_error_message(_m("Name can not be empty"), "admin");
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=cfields");
             break;
         default:
             $categories = Category::newInstance()->toTreeAll();
             $selected = array();
             foreach ($categories as $c) {
                 $selected[] = $c['pk_i_id'];
                 foreach ($c['categories'] as $cc) {
                     $selected[] = $cc['pk_i_id'];
                 }
             }
             $this->_exportVariableToView("categories", $categories);
             $this->_exportVariableToView("default_selected", $selected);
             $this->_exportVariableToView("fields", $this->fieldManager->listAll());
             $this->doView("fields/index.php");
     }
 }
开发者ID:acharei,项目名称:OSClass,代码行数:35,代码来源:custom_fields.php

示例4: update_cat_stats

function update_cat_stats()
{
    //$manager = CategoryStats::newInstance();
    $conn = getConnection();
    $sql_cats = "SELECT pk_i_id FROM " . DB_TABLE_PREFIX . "t_category";
    $cats = $conn->osc_dbFetchResults($sql_cats);
    foreach ($cats as $c) {
        $date = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
        $sql = sprintf("SELECT COUNT(pk_i_id) as total, fk_i_category_id as category FROM `%st_item` WHERE `dt_pub_date` > '%s' AND fk_i_category_id = %d GROUP BY fk_i_category_id", DB_TABLE_PREFIX, $date, $c['pk_i_id']);
        $total = $conn->osc_dbFetchResult($sql);
        $total = $total['total'];
        /*$manager->update(
          array(
              'i_num_items' => $total
              ), array('fk_i_category_id' => $c['pk_i_id'])
          );*/
        $conn->osc_dbExec("INSERT INTO %st_category_stats (fk_i_category_id, i_num_items) VALUES (%d, %d) ON DUPLICATE KEY UPDATE i_num_items = %d", DB_TABLE_PREFIX, $c['pk_i_id'], $total, $total);
    }
    $categories = Category::newInstance()->findRootCategories();
    foreach ($categories as $c) {
        /*$manager->update(
        			array(
        				'i_num_items' => count_items_subcategories($c)
        			), array('fk_i_category_id' => $c['pk_i_id'])
        		);*/
        $total = count_items_subcategories($c);
        //$conn->osc_dbExec("INSERT INTO %st_category_stats (fk_i_category_id, i_num_items) VALUES (%d, %d) ON DUPLICATE KEY UPDATE i_num_items = %d", DB_TABLE_PREFIX, $c['pk_i_id'], $total, $total);
    }
}
开发者ID:hashemgamal,项目名称:OSClass,代码行数:29,代码来源:cron.hourly.php

示例5: decreaseNumItems

 public function decreaseNumItems($categoryId)
 {
     $this->conn->osc_dbExec('INSERT INTO %s (fk_i_category_id, i_num_items) VALUES (%d, 0) ON DUPLICATE KEY UPDATE i_num_items = i_num_items - 1', $this->getTableName(), $categoryId);
     $result = Category::newInstance()->findByPrimaryKey($categoryId);
     if ($result['fk_i_parent_id'] != NULL) {
         $this->decreaseNumItems($result['fk_i_parent_id']);
     }
 }
开发者ID:hashemgamal,项目名称:OSClass,代码行数:8,代码来源:CategoryStats.php

示例6: update_cat_stats

function update_cat_stats()
{
    $conn = getConnection();
    $sql_cats = "SELECT pk_i_id, i_expiration_days FROM " . DB_TABLE_PREFIX . "t_category";
    $cats = $conn->osc_dbFetchResults($sql_cats);
    foreach ($cats as $c) {
        if ($c['i_expiration_days'] == 0) {
            $sql = sprintf("SELECT COUNT(pk_i_id) as total, fk_i_category_id as category FROM `%st_item` WHERE fk_i_category_id = %d AND b_enabled = 1 AND b_active = 1 GROUP BY fk_i_category_id", DB_TABLE_PREFIX, $c['pk_i_id']);
        } else {
            $sql = sprintf("SELECT COUNT(pk_i_id) as total, fk_i_category_id as category FROM `%st_item` WHERE fk_i_category_id = %d AND b_enabled = 1 AND b_active = 1 AND (b_premium = 1 || TIMESTAMPDIFF(DAY,dt_pub_date,'%s') < %d) GROUP BY fk_i_category_id", DB_TABLE_PREFIX, $c['pk_i_id'], date('Y-m-d H:i:s'), $c['i_expiration_days']);
        }
        $total = $conn->osc_dbFetchResult($sql);
        $total = $total['total'];
        $conn->osc_dbExec("INSERT INTO %st_category_stats (fk_i_category_id, i_num_items) VALUES (%d, %d) ON DUPLICATE KEY UPDATE i_num_items = %d", DB_TABLE_PREFIX, $c['pk_i_id'], $total, $total);
    }
    $categories = Category::newInstance()->findRootCategories();
    foreach ($categories as $c) {
        $total = count_items_subcategories($c);
    }
}
开发者ID:nsswaga,项目名称:OSClass,代码行数:20,代码来源:cron.hourly.php

示例7: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         default:
             $categories = Category::newInstance()->toTreeAll();
             $selected = array();
             foreach ($categories as $c) {
                 $selected[] = $c['pk_i_id'];
                 foreach ($c['categories'] as $cc) {
                     $selected[] = $cc['pk_i_id'];
                 }
             }
             $this->_exportVariableToView('categories', $categories);
             $this->_exportVariableToView('default_selected', $selected);
             $this->_exportVariableToView('fields', $this->fieldManager->listAll());
             $this->doView("fields/index.php");
             break;
     }
 }
开发者ID:jmcclenon,项目名称:Osclass,代码行数:21,代码来源:custom_fields.php

示例8: osc_premium_category_description

/**
 * Gets category description from current premium, if $locale is unspecified $locale is current user locale
 *
 * @param type $locale
 * @return string 
 */
function osc_premium_category_description($locale = "")
{
    if ($locale == "") {
        $locale = osc_current_user_locale();
    }
    if (!View::newInstance()->_exists('premium_category')) {
        View::newInstance()->_exportVariableToView('premium_category', Category::newInstance()->findByPrimaryKey(osc_premium_category_id()));
    }
    $category = View::newInstance()->_get('premium_category');
    return osc_field($category, "s_description", $locale);
}
开发者ID:acharei,项目名称:OSClass,代码行数:17,代码来源:hPremium.php

示例9: prepareData

        /**
         * Return an array with all data necessary for do the action (ADD OR EDIT)
         * @param <type> $is_add
         * @return array
         */
        public function prepareData( $is_add )
        {
            $aItem = array();
            $data = array();

            $userId = null;
            if( $this->is_admin ) {
                // user
                $data   = User::newInstance()->findByEmail(Params::getParam('contactEmail'));
                if( isset($data['pk_i_id']) && is_numeric($data['pk_i_id']) ) {
                    $userId = $data['pk_i_id'];
                }
            } else {
                $userId = Session::newInstance()->_get('userId');
                if( $userId == '' ) {
                    $userId = NULL;
                } elseif ($userId != NULL) {
                    $data   = User::newInstance()->findByPrimaryKey( $userId );
                }
            }

            if( $userId != null ) {
                $aItem['contactName']   = $data['s_name'];
                $aItem['contactEmail']  = $data['s_email'];
                Params::setParam('contactName', $data['s_name']);
                Params::setParam('contactEmail', $data['s_email']);
            } else {
                $aItem['contactName']   = Params::getParam('contactName');
                $aItem['contactEmail']  = Params::getParam('contactEmail');
            }
            $aItem['userId']        = $userId;

            if( $is_add ) {   // ADD
                if($this->is_admin) {
                    $active = 'ACTIVE';
                } else {
                    if(osc_moderate_items()>0) { // HAS TO VALIDATE
                        if(!osc_is_web_user_logged_in()) { // NO USER IS LOGGED, VALIDATE
                            $active = 'INACTIVE';
                        } else { // USER IS LOGGED
                            if(osc_logged_user_item_validation()) { //USER IS LOGGED, BUT NO NEED TO VALIDATE
                                $active = 'ACTIVE';
                            } else { // USER IS LOGGED, NEED TO VALIDATE, CHECK NUMBER OF PREVIOUS ITEMS
                                $user = User::newInstance()->findByPrimaryKey(osc_logged_user_id());
                                if($user['i_items']<osc_moderate_items()) {
                                    $active = 'INACTIVE';
                                } else {
                                    $active = 'ACTIVE';
                                }
                            }
                        }
                    } else if(osc_moderate_items()==0 ){
                        if(osc_is_web_user_logged_in() && osc_logged_user_item_validation() ) {
                            $active = 'ACTIVE';
                        } else {
                            $active = 'INACTIVE';
                        }
                    } else {
                        $active = 'ACTIVE';
                    }
                }
                $aItem['active']        = $active;
            } else {          // EDIT
                $aItem['secret']    = Params::getParam('secret');
                $aItem['idItem']    = Params::getParam('id');
            }

            // get params
            $aItem['catId']         = Params::getParam('catId');
            $aItem['countryId']     = Params::getParam('countryId');
            $aItem['country']       = Params::getParam('country');
            $aItem['region']        = Params::getParam('region');
            $aItem['regionId']      = Params::getParam('regionId');
            $aItem['city']          = Params::getParam('city');
            $aItem['cityId']        = Params::getParam('cityId');
            $aItem['price']         = (Params::getParam('price') != '') ? Params::getParam('price') : null;
            $aItem['cityArea']      = Params::getParam('cityArea');
            $aItem['address']       = Params::getParam('address');
            $aItem['currency']      = Params::getParam('currency');
            $aItem['showEmail']     = (Params::getParam('showEmail') != '') ? 1 : 0;
            $aItem['title']         = Params::getParam('title');
            $aItem['description']   = Params::getParam('description');
            $aItem['photos']        = Params::getFiles('photos');
            $ajax_photos            = Params::getParam('ajax_photos');
            $aItem['s_ip']          = get_ip();
            $aItem['d_coord_lat']   = (Params::getParam('d_coord_lat')  != '') ? Params::getParam('d_coord_lat') : null;
            $aItem['d_coord_long']  = (Params::getParam('d_coord_long') != '') ? Params::getParam('d_coord_long') : null;
            $aItem['s_zip']         = (Params::getParam('zip')  != '') ? Params::getParam('zip') : null;

            // $ajax_photos is an array of filenames of the photos uploaded by ajax to a temporary folder
            // fake insert them into the array of the form-uploaded photos
            if(is_array($ajax_photos)) {
                foreach($ajax_photos as $photo) {
                    if(file_exists(osc_content_path().'uploads/temp/'.$photo)) {
                        $aItem['photos']['name'][]      = $photo;
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:101,代码来源:ItemActions.php

示例10: edit

 function edit()
 {
     $aItem = $this->data;
     $flash_error = '';
     // Sanitize
     foreach (@$aItem['title'] as $key => $value) {
         $aItem['title'][$key] = strip_tags(trim($value));
     }
     $aItem['price'] = !is_null($aItem['price']) ? strip_tags(trim($aItem['price'])) : $aItem['price'];
     $aItem['cityArea'] = osc_sanitize_name(strip_tags(trim($aItem['cityArea'])));
     $aItem['address'] = osc_sanitize_name(strip_tags(trim($aItem['address'])));
     // Validate
     if (!$this->checkAllowedExt($aItem['photos'])) {
         $flash_error .= _m("Image with an incorrect extension.") . PHP_EOL;
     }
     if (!$this->checkSize($aItem['photos'])) {
         $flash_error .= _m("Image is too big. Max. size") . osc_max_size_kb() . " Kb" . PHP_EOL;
     }
     $title_message = '';
     $td_message = '';
     foreach (@$aItem['title'] as $key => $value) {
         if (osc_validate_text($value, 1) && osc_validate_max($value, 100)) {
             $td_message = '';
             break;
         }
         $td_message .= (!osc_validate_text($value, 1) ? _m("Title too short.") . PHP_EOL : '') . (!osc_validate_max($value, 100) ? _m("Title too long.") . PHP_EOL : '');
     }
     $flash_error .= $td_message;
     $desc_message = '';
     foreach (@$aItem['description'] as $key => $value) {
         if (osc_validate_text($value, 3) && osc_validate_max($value, 5000)) {
             $desc_message = '';
             break;
         }
         $desc_message .= (!osc_validate_text($value, 3) ? _m("Description too short.") . PHP_EOL : '') . (!osc_validate_max($value, 5000) ? _m("Description too long.") . PHP_EOL : '');
     }
     $flash_error .= $desc_message;
     $flash_error .= (!osc_validate_category($aItem['catId']) ? _m("Category invalid.") . PHP_EOL : '') . (!osc_validate_number($aItem['price']) ? _m("Price must be a number.") . PHP_EOL : '') . (!osc_validate_max($aItem['price'], 15) ? _m("Price too long.") . PHP_EOL : '') . (!osc_validate_text($aItem['countryName'], 3, false) ? _m("Country too short.") . PHP_EOL : '') . (!osc_validate_max($aItem['countryName'], 50) ? _m("Country too long.") . PHP_EOL : '') . (!osc_validate_text($aItem['regionName'], 3, false) ? _m("Region too short.") . PHP_EOL : '') . (!osc_validate_max($aItem['regionName'], 50) ? _m("Region too long.") . PHP_EOL : '') . (!osc_validate_text($aItem['cityName'], 3, false) ? _m("City too short.") . PHP_EOL : '') . (!osc_validate_max($aItem['cityName'], 50) ? _m("City too long.") . PHP_EOL : '') . (!osc_validate_text($aItem['cityArea'], 3, false) ? _m("Municipality too short.") . PHP_EOL : '') . (!osc_validate_max($aItem['cityArea'], 50) ? _m("Municipality too long.") . PHP_EOL : '') . (!osc_validate_text($aItem['address'], 3, false) ? _m("Address too short.") . PHP_EOL : '') . (!osc_validate_max($aItem['address'], 100) ? _m("Address too long.") . PHP_EOL : '');
     $_meta = Field::newInstance()->findByCategory($aItem['catId']);
     $meta = Params::getParam("meta");
     foreach ($_meta as $_m) {
         $meta[$_m['pk_i_id']] = isset($meta[$_m['pk_i_id']]) ? $meta[$_m['pk_i_id']] : '';
     }
     if ($meta != '' && count($meta) > 0) {
         $mField = Field::newInstance();
         foreach ($meta as $k => $v) {
             if ($v == '') {
                 $field = $mField->findByPrimaryKey($k);
                 if ($field['b_required'] == 1) {
                     $flash_error .= sprintf(_m("%s field is required."), $field['s_name']);
                 }
             }
         }
     }
     // hook pre add or edit
     osc_run_hook('pre_item_post');
     // Handle error
     if ($flash_error) {
         return $flash_error;
     } else {
         $location = array('fk_c_country_code' => $aItem['countryId'], 's_country' => $aItem['countryName'], 'fk_i_region_id' => $aItem['regionId'], 's_region' => $aItem['regionName'], 'fk_i_city_id' => $aItem['cityId'], 's_city' => $aItem['cityName'], 's_city_area' => $aItem['cityArea'], 's_address' => $aItem['address']);
         $locationManager = ItemLocation::newInstance();
         $old_item_location = $locationManager->findByPrimaryKey($aItem['idItem']);
         $locationManager->update($location, array('fk_i_item_id' => $aItem['idItem']));
         $old_item = $this->manager->findByPrimaryKey($aItem['idItem']);
         if ($aItem['userId'] != '') {
             $user = User::newInstance()->findByPrimaryKey($aItem['userId']);
             $aItem['userId'] = $aItem['userId'];
             $aItem['contactName'] = $user['s_name'];
             $aItem['contactEmail'] = $user['s_email'];
         } else {
             $aItem['userId'] = NULL;
         }
         if ($aItem['price'] != '') {
             $aItem['currency'] = $aItem['currency'];
         } else {
             $aItem['currency'] = NULL;
         }
         $aUpdate = array('dt_mod_date' => date('Y-m-d H:i:s'), 'fk_i_category_id' => $aItem['catId'], 'i_price' => $aItem['price'], 'fk_c_currency_code' => $aItem['currency']);
         // only can change the user if you're an admin
         if ($this->is_admin) {
             $aUpdate['fk_i_user_id'] = $aItem['userId'];
             $aUpdate['s_contact_name'] = $aItem['contactName'];
             $aUpdate['s_contact_email'] = $aItem['contactEmail'];
         }
         $result = $this->manager->update($aUpdate, array('pk_i_id' => $aItem['idItem'], 's_secret' => $aItem['secret']));
         // UPDATE title and description locales
         $this->insertItemLocales('EDIT', $aItem['title'], $aItem['description'], $aItem['idItem']);
         // UPLOAD item resources
         $this->uploadItemResources($aItem['photos'], $aItem['idItem']);
         Log::newInstance()->insertLog('item', 'edit', $aItem['idItem'], current(array_values($aItem['title'])), $this->is_admin ? 'admin' : 'user', $this->is_admin ? osc_logged_admin_id() : osc_logged_user_id());
         /**
          * META FIELDS
          */
         if ($meta != '' && count($meta) > 0) {
             $mField = Field::newInstance();
             foreach ($meta as $k => $v) {
                 $mField->replace($aItem['idItem'], $k, $v);
             }
         }
//.........这里部分代码省略.........
开发者ID:ranjithinnergys,项目名称:OSClass,代码行数:101,代码来源:ItemActions.php

示例11: breadcrumbs_category_url

function breadcrumbs_category_url($category_id)
{
    $path = '';
    if (osc_rewrite_enabled()) {
        if ($category_id != '') {
            $category = Category::newInstance()->hierarchy($category_id);
            $sanitized_category = "";
            for ($i = count($category); $i > 0; $i--) {
                $sanitized_category .= $category[$i - 1]['s_slug'] . '/';
            }
            $path = osc_base_url() . $sanitized_category;
        }
    } else {
        $path = sprintf(osc_base_url(true) . '?page=search&sCategory=%d', $category_id);
    }
    return rtrim($path, "/");
}
开发者ID:oanav,项目名称:closetshare,代码行数:17,代码来源:index.php

示例12: meta_title

 function meta_title()
 {
     $location = Rewrite::newInstance()->get_location();
     $section = Rewrite::newInstance()->get_section();
     switch ($location) {
         case 'item':
             switch ($section) {
                 case 'item_add':
                     $text = __('Publish an item', 'modern') . ' - ' . osc_page_title();
                     break;
                 case 'item_edit':
                     $text = __('Edit your item', 'modern') . ' - ' . osc_page_title();
                     break;
                 case 'send_friend':
                     $text = __('Send to a friend', 'modern') . ' - ' . osc_item_title() . ' - ' . osc_page_title();
                     break;
                 case 'contact':
                     $text = __('Contact seller', 'modern') . ' - ' . osc_item_title() . ' - ' . osc_page_title();
                     break;
                 default:
                     $text = osc_item_title() . ' - ' . osc_page_title();
                     break;
             }
             break;
         case 'page':
             $text = osc_static_page_title() . ' - ' . osc_page_title();
             break;
         case 'error':
             $text = __('Error', 'modern') . ' - ' . osc_page_title();
             break;
         case 'search':
             $region = Params::getParam('sRegion');
             $city = Params::getParam('sCity');
             $pattern = Params::getParam('sPattern');
             $category = osc_search_category_id();
             $category = count($category) == 1 ? $category[0] : '';
             $s_page = '';
             $i_page = Params::getParam('iPage');
             if ($i_page != '' && $i_page > 0) {
                 $s_page = __('page', 'modern') . ' ' . ($i_page + 1) . ' - ';
             }
             $b_show_all = $region == '' && $city == '' & $pattern == '' && $category == '';
             $b_category = $category != '';
             $b_pattern = $pattern != '';
             $b_city = $city != '';
             $b_region = $region != '';
             if ($b_show_all) {
                 $text = __('Show all items', 'modern') . ' - ' . $s_page . osc_page_title();
             }
             $result = '';
             if ($b_pattern) {
                 $result .= $pattern . ' &raquo; ';
             }
             if ($b_category) {
                 $list = array();
                 $aCategories = Category::newInstance()->toRootTree($category);
                 if (count($aCategories) > 0) {
                     foreach ($aCategories as $single) {
                         $list[] = $single['s_name'];
                     }
                     $result .= implode(' &raquo; ', $list) . ' &raquo; ';
                 }
             }
             if ($b_city) {
                 $result .= $city . ' &raquo; ';
             }
             if ($b_region) {
                 $result .= $region . ' &raquo; ';
             }
             $result = preg_replace('|\\s?&raquo;\\s$|', '', $result);
             if ($result == '') {
                 $result = __('Search', 'modern');
             }
             $text = $result . ' - ' . $s_page . osc_page_title();
             break;
         case 'login':
             switch ($section) {
                 case 'recover':
                     $text = __('Recover your password', 'modern') . ' - ' . osc_page_title();
                 default:
                     $text = __('Login', 'modern') . ' - ' . osc_page_title();
             }
             break;
         case 'register':
             $text = __('Create a new account', 'modern') . ' - ' . osc_page_title();
             break;
         case 'user':
             switch ($section) {
                 case 'dashboard':
                     $text = __('Dashboard', 'modern') . ' - ' . osc_page_title();
                     break;
                 case 'items':
                     $text = __('Manage my items', 'modern') . ' - ' . osc_page_title();
                     break;
                 case 'alerts':
                     $text = __('Manage my alerts', 'modern') . ' - ' . osc_page_title();
                     break;
                 case 'profile':
                     $text = __('Update my profile', 'modern') . ' - ' . osc_page_title();
                     break;
//.........这里部分代码省略.........
开发者ID:acharei,项目名称:OSClass,代码行数:101,代码来源:functions.php

示例13: osc_search_category_id

/**
 * Gets current search category id
 *
 * @return int
 */
function osc_search_category_id()
{
    $categories = osc_search_category();
    $category = array();
    $where = array();
    foreach ($categories as $cat) {
        if (is_numeric($cat)) {
            $where[] = "a.pk_i_id = " . $cat;
        } else {
            $slug_cat = explode("/", trim($cat, "/"));
            $where[] = "b.s_slug = '" . $slug_cat[count($slug_cat) - 1] . "'";
        }
    }
    if (empty($where)) {
        return null;
    } else {
        $categories = Category::newInstance()->listWhere(implode(" OR ", $where));
        foreach ($categories as $cat) {
            $category[] = $cat['pk_i_id'];
        }
        return $category;
    }
}
开发者ID:acharei,项目名称:OSClass,代码行数:28,代码来源:hSearch.php

示例14: item_category_select

function item_category_select($default_option)
{
    $categories = Category::newInstance()->findRootCategoriesEnabled();
    ?>
        <?php 
    if (count($categories) > 0) {
        ?>
        <select class="category">
            <option><?php 
        echo $default_option;
        ?>
</option>
            <?php 
        foreach ($categories as $c) {
            ?>
            <option value="<?php 
            echo $c['pk_i_id'];
            ?>
"><?php 
            echo $c['s_name'];
            ?>
</option>
            <?php 
        }
        ?>
        </select>
        <?php 
    }
    ?>
        <select class="subcategory" name="catId" style="display:none"></select>
        <?php 
}
开发者ID:jhalendra,项目名称:classmandu,代码行数:32,代码来源:functions.php

示例15: doModel

 function doModel()
 {
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             break;
         case 'regions':
             //Return regions given a countryId
             $regions = Region::newInstance()->findByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->findByRegion(Params::getParam("regionId"));
             echo json_encode($cities);
             break;
         case 'location':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($cities);
             break;
         case 'userajax':
             // This is the autocomplete AJAX
             $users = User::newInstance()->ajax(Params::getParam("term"));
             if (count($users) == 0) {
                 echo json_encode(array(0 => array('id' => '', 'label' => __('No results'), 'value' => __('No results'))));
             } else {
                 echo json_encode($users);
             }
             break;
         case 'date_format':
             echo json_encode(array('format' => Params::getParam('format'), 'str_formatted' => osc_format_date(date('Y-m-d H:i:s'), Params::getParam('format'))));
             break;
         case 'runhook':
             // run hooks
             $hook = Params::getParam('hook');
             if ($hook == '') {
                 echo json_encode(array('error' => 'hook parameter not defined'));
                 break;
             }
             switch ($hook) {
                 case 'item_form':
                     osc_run_hook('item_form', Params::getParam('catId'));
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     osc_run_hook('ajax_admin_' . $hook);
                     break;
             }
             break;
         case 'categories_order':
             // Save the order of the categories
             osc_csrf_check(false);
             $aIds = Params::getParam('list');
             $orderParent = 0;
             $orderSub = 0;
             $catParent = 0;
             $error = 0;
             $catManager = Category::newInstance();
             $aRecountCat = array();
             foreach ($aIds as $id => $parent) {
                 if ($parent == 'root') {
                     $res = $catManager->updateOrder($id, $orderParent);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                     // find category
                     $auxCategory = Category::newInstance()->findByPrimaryKey($id);
                     // set parent category
                     $conditions = array('pk_i_id' => $id);
                     $array['fk_i_parent_id'] = NULL;
                     $res = $catManager->update($array, $conditions);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     } else {
                         if ($res == 1) {
                             // updated ok
                             $parentId = $auxCategory['fk_i_parent_id'];
                             if ($parentId) {
                                 // update parent category stats
                                 array_push($aRecountCat, $id);
                                 array_push($aRecountCat, $parentId);
                             }
                         }
                     }
                     $orderParent++;
                 } else {
                     if ($parent != $catParent) {
                         $catParent = $parent;
                         $orderSub = 0;
                     }
                     $res = $catManager->updateOrder($id, $orderSub);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                     // set parent category
//.........这里部分代码省略.........
开发者ID:jmcclenon,项目名称:Osclass,代码行数:101,代码来源:ajax.php


注:本文中的Category::newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。