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


PHP Currency::newInstance方法代码示例

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


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

示例1: doModel

    function doModel()
    {
        switch ($this->action) {
            case 'comments':
                //calling the comments settings view
                $this->doView('settings/comments.php');
                break;
            case 'comments_post':
                // updating comment
                $iUpdated = 0;
                $enabledComments = Params::getParam('enabled_comments');
                $enabledComments = $enabledComments != '' ? true : false;
                $moderateComments = Params::getParam('moderate_comments');
                $moderateComments = $moderateComments != '' ? true : false;
                $numModerateComments = Params::getParam('num_moderate_comments');
                $commentsPerPage = Params::getParam('comments_per_page');
                $notifyNewComment = Params::getParam('notify_new_comment');
                $notifyNewComment = $notifyNewComment != '' ? true : false;
                $notifyNewCommentUser = Params::getParam('notify_new_comment_user');
                $notifyNewCommentUser = $notifyNewCommentUser != '' ? true : false;
                $regUserPostComments = Params::getParam('reg_user_post_comments');
                $regUserPostComments = $regUserPostComments != '' ? true : false;
                $msg = '';
                if (!osc_validate_int(Params::getParam("num_moderate_comments"))) {
                    $msg .= _m("Number of moderate comments must only contain numeric characters") . "<br/>";
                }
                if (!osc_validate_int(Params::getParam("comments_per_page"))) {
                    $msg .= _m("Comments per page must only contain numeric characters") . "<br/>";
                }
                if ($msg != '') {
                    osc_add_flash_error_message($msg, 'admin');
                    $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
                }
                $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
                if ($moderateComments) {
                    $iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
                } else {
                    $iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
                }
                $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewCommentUser), array('s_name' => 'notify_new_comment_user'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $commentsPerPage), array('s_name' => 'comments_per_page'));
                $iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPostComments), array('s_name' => 'reg_user_post_comments'));
                if ($iUpdated > 0) {
                    osc_add_flash_ok_message(_m("Comment settings have been updated"), 'admin');
                }
                $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
                break;
            case 'locations':
                // calling the locations settings view
                $location_action = Params::getParam('type');
                $mCountries = new Country();
                switch ($location_action) {
                    case 'add_country':
                        // add country
                        $countryCode = strtoupper(Params::getParam('c_country'));
                        $countryName = Params::getParam('country');
                        $exists = $mCountries->findByCode($countryCode);
                        if (isset($exists['s_name'])) {
                            osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
                        } else {
                            $countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country_code&term=' . urlencode($countryCode));
                            $countries = json_decode($countries_json);
                            $mCountries->insert(array('pk_c_code' => $countryCode, 's_name' => $countryName));
                            CountryStats::newInstance()->setNumItems($countryCode, 0);
                            if (isset($countries->error)) {
                                // Country is not in our GEO database
                                // We have no region for user-typed countries
                            } else {
                                // Country is in our GEO database, add regions and cities
                                $manager_region = new Region();
                                $regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country_code=' . urlencode($countryCode) . '&term=all');
                                $regions = json_decode($regions_json);
                                if (!isset($regions->error)) {
                                    if (count($regions) > 0) {
                                        foreach ($regions as $r) {
                                            $manager_region->insert(array("fk_c_country_code" => $r->country_code, "s_name" => $r->name));
                                            $id = $manager_region->dao->insertedId();
                                            RegionStats::newInstance()->setNumItems($id, 0);
                                        }
                                    }
                                    unset($regions);
                                    unset($regions_json);
                                    $manager_city = new City();
                                    if (count($countries) > 0) {
                                        foreach ($countries as $c) {
                                            $regions = $manager_region->findByCountry($c->id);
                                            if (!isset($regions->error)) {
                                                if (count($regions) > 0) {
                                                    foreach ($regions as $region) {
                                                        $cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '&region=' . urlencode($region['s_name']) . '&term=all');
                                                        $cities = json_decode($cities_json);
                                                        if (!isset($cities->error)) {
                                                            if (count($cities) > 0) {
                                                                foreach ($cities as $ci) {
                                                                    $manager_city->insert(array("fk_i_region_id" => $region['pk_i_id'], "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
                                                                    $id = $manager_city->dao->insertedId();
                                                                    CityStats::newInstance()->setNumItems($id, 0);
                                                                }
                                                            }
//.........这里部分代码省略.........
开发者ID:semul,项目名称:Osclass,代码行数:101,代码来源:settings.php

示例2: osc_get_currencies

/**
 * Gets list of currencies
 *
 * @return string
 */
function osc_get_currencies()
{
    if (!View::newInstance()->_exists('currencies')) {
        View::newInstance()->_exportVariableToView('currencies', Currency::newInstance()->listAll());
    }
    return View::newInstance()->_get('currencies');
}
开发者ID:randomecho,项目名称:OSClass,代码行数:12,代码来源:hDefines.php

示例3: doModel

 function doModel()
 {
     switch (Params::getParam('type')) {
         case 'add':
             // calling add currency view
             $aCurrency = array('pk_c_code' => '', 's_name' => '', 's_description' => '');
             $this->_exportVariableToView('aCurrency', $aCurrency);
             $this->_exportVariableToView('typeForm', 'add_post');
             $this->doView('settings/currency_form.php');
             break;
         case 'add_post':
             // adding a new currency
             osc_csrf_check();
             $currencyCode = Params::getParam('pk_c_code');
             $currencyName = Params::getParam('s_name');
             $currencyDescription = Params::getParam('s_description');
             // cleaning parameters
             $currencyName = trim(strip_tags($currencyName));
             $currencyDescription = trim(strip_tags($currencyDescription));
             $currencyCode = trim(strip_tags($currencyCode));
             if (!preg_match('/^.{1,3}$/', $currencyCode)) {
                 osc_add_flash_error_message(_m('The currency code is not in the correct format'), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=currencies');
             }
             $fields = array('pk_c_code' => $currencyCode, 's_name' => $currencyName, 's_description' => $currencyDescription);
             $isInserted = Currency::newInstance()->insert($fields);
             if ($isInserted) {
                 osc_add_flash_ok_message(_m('Currency added'), 'admin');
             } else {
                 osc_add_flash_error_message(_m("Currency couldn't be added"), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=currencies');
             break;
         case 'edit':
             // calling edit currency view
             $currencyCode = Params::getParam('code');
             $currencyCode = trim(strip_tags($currencyCode));
             if ($currencyCode == '') {
                 osc_add_flash_warning_message(sprintf(_m("The currency code '%s' doesn't exist"), $currencyCode), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=currencies');
             }
             $aCurrency = Currency::newInstance()->findByPrimaryKey($currencyCode);
             if (!$aCurrency) {
                 osc_add_flash_warning_message(sprintf(_m("The currency code '%s' doesn't exist"), $currencyCode), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=currencies');
             }
             $this->_exportVariableToView('aCurrency', $aCurrency);
             $this->_exportVariableToView('typeForm', 'edit_post');
             $this->doView('settings/currency_form.php');
             break;
         case 'edit_post':
             // updating currency
             osc_csrf_check();
             $currencyName = Params::getParam('s_name');
             $currencyDescription = Params::getParam('s_description');
             $currencyCode = Params::getParam('pk_c_code');
             // cleaning parameters
             $currencyName = trim(strip_tags($currencyName));
             $currencyDescription = trim(strip_tags($currencyDescription));
             $currencyCode = trim(strip_tags($currencyCode));
             if (!preg_match('/.{1,3}/', $currencyCode)) {
                 osc_add_flash_error_message(_m('Error: the currency code is not in the correct format'), 'admin');
                 $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=currencies');
             }
             $updated = Currency::newInstance()->update(array('s_name' => $currencyName, 's_description' => $currencyDescription), array('pk_c_code' => $currencyCode));
             if ($updated == 1) {
                 osc_add_flash_ok_message(_m('Currency updated'), 'admin');
             } else {
                 osc_add_flash_info_message(_m('No changes were made'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=currencies');
             break;
         case 'delete':
             // deleting a currency
             osc_csrf_check();
             $rowChanged = 0;
             $aCurrencyCode = Params::getParam('code');
             if (!is_array($aCurrencyCode)) {
                 $aCurrencyCode = array($aCurrencyCode);
             }
             $msg_current = '';
             foreach ($aCurrencyCode as $currencyCode) {
                 if (preg_match('/.{1,3}/', $currencyCode) && $currencyCode != osc_currency()) {
                     $rowChanged += Currency::newInstance()->delete(array('pk_c_code' => $currencyCode));
                 }
                 // foreign key error
                 if (Currency::newInstance()->getErrorLevel() == '1451') {
                     $msg_current .= sprintf('</p><p>' . _m("%s couldn't be deleted because it has listings associated to it"), $currencyCode);
                 } else {
                     if ($currencyCode == osc_currency()) {
                         $msg_current .= sprintf('</p><p>' . _m("%s couldn't be deleted because it's the default currency"), $currencyCode);
                     }
                 }
             }
             $msg = '';
             $status = '';
             switch ($rowChanged) {
                 case '0':
                     $msg = _m('No currencies have been deleted');
                     $status = 'error';
//.........这里部分代码省略.........
开发者ID:oanav,项目名称:closetshare,代码行数:101,代码来源:currencies.php

示例4: doModel


//.........这里部分代码省略.........
                    $contactAttachment = Params::getParam('enabled_attachment');
                    $selectableParent  = Params::getParam('selectable_parent_categories');
                    $bAutoCron         = Params::getParam('auto_cron');
                    $bMarketSources    = (Params::getParam('market_external_sources') != '' ? true: false);
                    $sAutoUpdate       = join("|", Params::getParam('auto_update'));

                    // preparing parameters
                    $sPageTitle        = trim(strip_tags($sPageTitle));
                    $sPageDesc         = trim(strip_tags($sPageDesc));
                    $sContactEmail     = trim(strip_tags($sContactEmail));
                    $sLanguage         = trim(strip_tags($sLanguage));
                    $sDateFormat       = trim(strip_tags($sDateFormat));
                    $sCurrency         = trim(strip_tags($sCurrency));
                    $sWeekStart        = trim(strip_tags($sWeekStart));
                    $sTimeFormat       = trim(strip_tags($sTimeFormat));
                    $sNumRssItems      = (int) trim(strip_tags($sNumRssItems));
                    $maxLatestItems    = (int) trim(strip_tags($maxLatestItems));
                    $numItemsSearch    = (int) $numItemsSearch;
                    $contactAttachment = ($contactAttachment != '' ? true : false);
                    $bAutoCron         = ($bAutoCron != '' ? true : false);
                    $error = "";

                    $msg = '';
                    if(!osc_validate_text($sPageTitle)) {
                        $msg .= _m("Page title field is required")."<br/>";
                    }
                    if(!osc_validate_text($sContactEmail)) {
                        $msg .= _m("Contact email field is required")."<br/>";
                    }
                    if(!osc_validate_int($sNumRssItems)) {
                        $msg .= _m("Number of listings in the RSS has to be a numeric value")."<br/>";
                    }
                    if(!osc_validate_int($maxLatestItems)) {
                        $msg .= _m("Max latest listings has to be a numeric value")."<br/>";
                    }
                    if(!osc_validate_int($numItemsSearch)) {
                        $msg .= _m("Number of listings on search has to be a numeric value")."<br/>";
                    }
                    if($msg!='') {
                        osc_add_flash_error_message( $msg, 'admin');
                        $this->redirectTo(osc_admin_base_url(true) . '?page=settings');
                    }

                    $iUpdated += osc_set_preference('pageTitle', $sPageTitle);
                    $iUpdated += osc_set_preference('pageDesc', $sPageDesc);

                    if( !defined('DEMO') ) {
                        $iUpdated += osc_set_preference('contactEmail', $sContactEmail);
                    }
                    $iUpdated += osc_set_preference('language', $sLanguage);
                    $iUpdated += osc_set_preference('dateFormat', $sDateFormat);
                    $iUpdated += osc_set_preference('currency', $sCurrency);
                    $iUpdated += osc_set_preference('weekStart', $sWeekStart);
                    $iUpdated += osc_set_preference('timeFormat', $sTimeFormat);
                    $iUpdated += osc_set_preference('timezone', $sTimezone);
                    $iUpdated += osc_set_preference('marketAllowExternalSources', $bMarketSources);
                    $iUpdated += osc_set_preference('auto_update', $sAutoUpdate);
                    if(is_int($sNumRssItems)) {
                        $iUpdated += osc_set_preference('num_rss_items', $sNumRssItems);
                    } else {
                        if($error != '') $error .= "</p><p>";
                        $error .= _m('Number of listings in the RSS must be an integer');
                    }

                    if(is_int($maxLatestItems)) {
                        $iUpdated += osc_set_preference('maxLatestItems@home', $maxLatestItems);
                    } else {
                        if($error != '') $error .= "</p><p>";
                        $error .= _m('Number of recent listings displayed at home must be an integer');
                    }

                    $iUpdated += osc_set_preference('defaultResultsPerPage@search', $numItemsSearch);
                    $iUpdated += osc_set_preference('contact_attachment', $contactAttachment);
                    $iUpdated += osc_set_preference('auto_cron', $bAutoCron);
                    $iUpdated += osc_set_preference('selectable_parent_categories', $selectableParent);

                    if( $iUpdated > 0 ) {
                        if( $error != '' ) {
                            osc_add_flash_error_message( $error . "</p><p>" . _m('General settings have been updated'), 'admin');
                        } else {
                            osc_add_flash_ok_message( _m('General settings have been updated'), 'admin');
                        }
                    } else if($error != '') {
                        osc_add_flash_error_message( $error , 'admin');
                    }

                    $this->redirectTo(osc_admin_base_url(true) . '?page=settings');
                break;
                default:
                    // calling the view
                    $aLanguages = OSCLocale::newInstance()->listAllEnabled();
                    $aCurrencies = Currency::newInstance()->listAll();

                    $this->_exportVariableToView('aLanguages', $aLanguages);
                    $this->_exportVariableToView('aCurrencies', $aCurrencies);

                    $this->doView('settings/index.php');
                break;
            }
        }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:101,代码来源:main.php

示例5: osc_item_currency_symbol

/**
 * Gets currency symbol of an item
 *
 * @since 3.0
 * @return string
 */
function osc_item_currency_symbol()
{
    $aCurrency = Currency::newInstance()->findByPrimaryKey(osc_item_currency());
    return $aCurrency['s_description'];
}
开发者ID:jmcclenon,项目名称:Osclass,代码行数:11,代码来源:hItems.php

示例6: doModel

 function doModel()
 {
     //calling the view...
     $locales = OSCLocale::newInstance()->listAllEnabled();
     $this->_exportVariableToView('locales', $locales);
     switch ($this->action) {
         case 'item_add':
             // post
             if (!osc_users_enabled()) {
                 osc_add_flash_message(_m('Users not enabled'));
                 $this->redirectTo(osc_base_url(true));
             }
             if (osc_reg_user_post() && $this->user == null) {
                 // CHANGEME: This text
                 osc_add_flash_message(_m('Only registered users are allowed to post items'));
                 $this->redirectTo(osc_user_login_url());
             }
             $countries = Country::newInstance()->listAll();
             $regions = array();
             if (isset($this->user['fk_c_country_code']) && $this->user['fk_c_country_code'] != '') {
                 $regions = Region::newInstance()->getByCountry($this->user['fk_c_country_code']);
             } else {
                 if (count($countries) > 0) {
                     $regions = Region::newInstance()->getByCountry($countries[0]['pk_c_code']);
                 }
             }
             $cities = array();
             if (isset($this->user['fk_i_region_id']) && $this->user['fk_i_region_id'] != '') {
                 $cities = City::newInstance()->listWhere("fk_i_region_id = %d", $this->user['fk_i_region_id']);
             } else {
                 if (count($regions) > 0) {
                     $cities = City::newInstance()->listWhere("fk_i_region_id = %d", $regions[0]['pk_i_id']);
                 }
             }
             $this->_exportVariableToView('countries', $countries);
             $this->_exportVariableToView('regions', $regions);
             $this->_exportVariableToView('cities', $cities);
             $this->_exportVariableToView('user', $this->user);
             osc_run_hook('post_item');
             $this->doView('item-post.php');
             break;
         case 'item_add_post':
             //post_item
             if (!osc_users_enabled()) {
                 osc_add_flash_message(_m('Users not allowed'));
                 $this->redirectTo(osc_base_url(true));
             }
             if (osc_reg_user_post() && $this->user == null) {
                 osc_add_flash_message(_m('Only registered users are allowed to post items'));
                 $this->redirectTo(osc_base_url(true));
             }
             // POST ITEM ( ADD ITEM )
             $mItems = new ItemActions(false);
             $success = $mItems->add();
             if ($success) {
                 $PcontactName = Params::getParam('contactName');
                 $PcontactEmail = Params::getParam('contactEmail');
                 $itemId = Params::getParam('itemId');
                 $item = array();
                 if (Session::newInstance()->_get('userId') == '') {
                     $mPages = new Page();
                     $aPage = $mPages->findByInternalName('email_new_item_non_register_user');
                     $locale = osc_current_user_locale();
                     $content = array();
                     if (isset($aPage['locale'][$locale]['s_title'])) {
                         $content = $aPage['locale'][$locale];
                     } else {
                         $content = current($aPage['locale']);
                     }
                     $item = $this->itemManager->findByPrimaryKey($itemId);
                     $item_url = osc_item_url();
                     // before page = user , action = item_edit
                     $edit_url = osc_item_edit_url($item['s_secret'], $itemId);
                     // before page = user , action = item_delete
                     $delete_url = osc_item_delete_url($item['s_secret'], $itemId);
                     $words = array();
                     $words[] = array('{ITEM_ID}', '{USER_NAME}', '{USER_EMAIL}', '{WEB_URL}', '{ITEM_TITLE}', '{ITEM_URL}', '{WEB_TITLE}', '{EDIT_LINK}', '{EDIT_URL}', '{DELETE_LINK}', '{DELETE_URL}');
                     $words[] = array($itemId, $PcontactName, $PcontactEmail, osc_base_url(), $item['s_title'], $item_url, osc_page_title(), '<a href="' . $edit_url . '">' . $edit_url . '</a>', $edit_url, '<a href="' . $delete_url . '">' . $delete_url . '</a>', $delete_url);
                     $title = osc_mailBeauty($content['s_title'], $words);
                     $body = osc_mailBeauty($content['s_text'], $words);
                     $emailParams = array('subject' => $title, 'to' => $PcontactEmail, 'to_name' => $PcontactName, 'body' => $body, 'alt_body' => $body);
                     osc_sendMail($emailParams);
                 }
                 osc_run_hook('posted_item', $item);
                 $category = Category::newInstance()->findByPrimaryKey(Params::getParam('catId'));
                 View::newInstance()->_exportVariableToView('category', $category);
                 $this->redirectTo(osc_search_category_url());
             } else {
                 $this->redirectTo(osc_item_post_url());
             }
             break;
         case 'item_edit':
             $secret = Params::getParam('secret');
             $id = Params::getParam('id');
             $item = $this->itemManager->listWhere("i.pk_i_id = '%s' AND ((i.s_secret = '%s' AND i.fk_i_user_id IS NULL) OR (i.fk_i_user_id = '%d'))", $id, $secret, $this->userId);
             if (count($item) == 1) {
                 $item = Item::newInstance()->findByPrimaryKey($id);
                 $categories = Category::newInstance()->toTree();
                 $countries = Country::newInstance()->listAll();
                 $regions = array();
//.........这里部分代码省略.........
开发者ID:hashemgamal,项目名称:OSClass,代码行数:101,代码来源:item.php

示例7: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'comments':
             //calling the comments settings view
             $this->doView('settings/comments.php');
             break;
         case 'comments_post':
             // updating comment
             $iUpdated = 0;
             $enabledComments = Params::getParam('enabled_comments');
             $enabledComments = $enabledComments != '' ? true : false;
             $moderateComments = Params::getParam('moderate_comments');
             $moderateComments = $moderateComments != '' ? true : false;
             $numModerateComments = Params::getParam('num_moderate_comments');
             $commentsPerPage = Params::getParam('comments_per_page');
             $notifyNewComment = Params::getParam('notify_new_comment');
             $notifyNewComment = $notifyNewComment != '' ? true : false;
             $regUserPostComments = Params::getParam('reg_user_post_comments');
             $regUserPostComments = $regUserPostComments != '' ? true : false;
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
             if ($moderateComments) {
                 $iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
             } else {
                 $iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
             }
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $commentsPerPage), array('s_name' => 'comments_per_page'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPostComments), array('s_name' => 'reg_user_post_comments'));
             if ($iUpdated > 0) {
                 osc_add_flash_ok_message(_m('Comments\' settings have been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
             break;
         case 'locations':
             // calling the locations settings view
             $location_action = Params::getParam('type');
             $mCountries = new Country();
             switch ($location_action) {
                 case 'add_country':
                     // add country
                     $countryCode = strtoupper(Params::getParam('c_country'));
                     $request = Params::getParam('country');
                     foreach ($request as $k => $v) {
                         $countryName = $v;
                         break;
                     }
                     $exists = $mCountries->findByCode($countryCode);
                     if (isset($exists['s_name'])) {
                         osc_add_flash_error_message(sprintf(_m('%s already was in the database'), $countryName), 'admin');
                     } else {
                         $countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country_code&term=' . urlencode($countryCode));
                         $countries = json_decode($countries_json);
                         foreach ($request as $k => $v) {
                             $data = array('pk_c_code' => $countryCode, 'fk_c_locale_code' => $k, 's_name' => $v);
                             $mCountries->insert($data);
                         }
                         if (isset($countries->error)) {
                             // Country is not in our GEO database
                             // We have no region for user-typed countries
                         } else {
                             // Country is in our GEO database, add regions and cities
                             $manager_region = new Region();
                             $regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country_code=' . urlencode($countryCode) . '&term=all');
                             $regions = json_decode($regions_json);
                             if (!isset($regions->error)) {
                                 if (count($regions) > 0) {
                                     foreach ($regions as $r) {
                                         $manager_region->insert(array("fk_c_country_code" => $r->country_code, "s_name" => $r->name));
                                     }
                                 }
                                 unset($regions);
                                 unset($regions_json);
                                 $manager_city = new City();
                                 if (count($countries) > 0) {
                                     foreach ($countries as $c) {
                                         $regions = $manager_region->listWhere('fk_c_country_code = \'' . $c->id . '\'');
                                         if (!isset($regions->error)) {
                                             if (count($regions) > 0) {
                                                 foreach ($regions as $region) {
                                                     $cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '&region=' . urlencode($region['s_name']) . '&term=all');
                                                     $cities = json_decode($cities_json);
                                                     if (!isset($cities->error)) {
                                                         if (count($cities) > 0) {
                                                             foreach ($cities as $ci) {
                                                                 $manager_city->insert(array("fk_i_region_id" => $region['pk_i_id'], "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
                                                             }
                                                         }
                                                     }
                                                     unset($cities);
                                                     unset($cities_json);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         osc_add_flash_ok_message(sprintf(_m('%s has been added as a new country'), $countryName), 'admin');
                     }
//.........这里部分代码省略.........
开发者ID:nsswaga,项目名称:OSClass,代码行数:101,代码来源:settings.php

示例8: doModel

 function doModel()
 {
     switch ($this->action) {
         case 'items':
             // calling the items settings view
             $this->doView('settings/items.php');
             break;
         case 'items_post':
             // update item settings
             $iUpdated = 0;
             $enabledRecaptchaItems = Params::getParam('enabled_recaptcha_items');
             $enabledRecaptchaItems = $enabledRecaptchaItems != '' ? true : false;
             $enabledItemValidation = Params::getParam('enabled_item_validation');
             $enabledItemValidation = $enabledItemValidation != '' ? true : false;
             $loggedUserItemValidation = Params::getParam('logged_user_item_validation');
             $loggedUserItemValidation = $loggedUserItemValidation != '' ? true : false;
             $regUserPost = Params::getParam('reg_user_post');
             $regUserPost = $regUserPost != '' ? true : false;
             $notifyNewItem = Params::getParam('notify_new_item');
             $notifyNewItem = $notifyNewItem != '' ? true : false;
             $notifyContactItem = Params::getParam('notify_contact_item');
             $notifyContactItem = $notifyContactItem != '' ? true : false;
             $notifyContactFriends = Params::getParam('notify_contact_friends');
             $notifyContactFriends = $notifyContactFriends != '' ? true : false;
             $enabledFieldPriceItems = Params::getParam('enableField#f_price@items');
             $enabledFieldPriceItems = $enabledFieldPriceItems != '' ? true : false;
             $enabledFieldImagesItems = Params::getParam('enableField#images@items');
             $enabledFieldImagesItems = $enabledFieldImagesItems != '' ? true : false;
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledRecaptchaItems), array('s_name' => 'enabled_recaptcha_items'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledItemValidation), array('s_name' => 'enabled_item_validation'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $loggedUserItemValidation), array('s_name' => 'logged_user_item_validation'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $regUserPost), array('s_name' => 'reg_user_post'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewItem), array('s_name' => 'notify_new_item'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyContactItem), array('s_name' => 'notify_contact_item'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyContactFriends), array('s_name' => 'notify_contact_friends'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledFieldPriceItems), array('s_name' => 'enableField#f_price@items'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledFieldImagesItems), array('s_name' => 'enableField#images@items'));
             if ($iUpdated > 0) {
                 osc_add_flash_message(_m('Items\' settings have been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=items');
             break;
         case 'comments':
             //calling the comments settings view
             $this->doView('settings/comments.php');
             break;
         case 'comments_post':
             // updating comment
             $iUpdated = 0;
             $enabledComments = Params::getParam('enabled_comments');
             $enabledComments = $enabledComments != '' ? true : false;
             $moderateComments = Params::getParam('moderate_comments');
             $moderateComments = $moderateComments != '' ? true : false;
             $numModerateComments = Params::getParam('num_moderate_comments');
             $notifyNewComment = Params::getParam('notify_new_comment');
             $notifyNewComment = $notifyNewComment != '' ? true : false;
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledComments), array('s_name' => 'enabled_comments'));
             if ($moderateComments) {
                 $iUpdated += Preference::newInstance()->update(array('s_value' => $numModerateComments), array('s_name' => 'moderate_comments'));
             } else {
                 $iUpdated += Preference::newInstance()->update(array('s_value' => '-1'), array('s_name' => 'moderate_comments'));
             }
             $iUpdated += Preference::newInstance()->update(array('s_value' => $notifyNewComment), array('s_name' => 'notify_new_comment'));
             if ($iUpdated > 0) {
                 osc_add_flash_message(_m('Comments\' settings have been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=comments');
             break;
         case 'users':
             // calling the users settings view
             $this->doView('settings/users.php');
             break;
         case 'users_post':
             // updating users
             $iUpdated = 0;
             $enabledUserValidation = Params::getParam('enabled_user_validation');
             $enabledUserValidation = $enabledUserValidation != '' ? true : false;
             $enabledUserRegistration = Params::getParam('enabled_user_registration');
             $enabledUserRegistration = $enabledUserRegistration != '' ? true : false;
             $enabledUsers = Params::getParam('enabled_users');
             $enabledUsers = $enabledUsers != '' ? true : false;
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserValidation), array('s_name' => 'enabled_user_validation'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUserRegistration), array('s_name' => 'enabled_user_registration'));
             $iUpdated += Preference::newInstance()->update(array('s_value' => $enabledUsers), array('s_name' => 'enabled_users'));
             if ($iUpdated > 0) {
                 osc_add_flash_message(_m('Users\' settings have been updated'), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=settings&action=users');
             break;
         case 'locations':
             // calling the locations settings view
             $location_action = Params::getParam('type');
             $mCountries = new Country();
             switch ($location_action) {
                 case 'add_country':
                     // add country
                     if (!Params::getParam('c_manual')) {
                         $this->install_location_by_country();
                     } else {
                         $countryCode = Params::getParam('c_country');
//.........这里部分代码省略.........
开发者ID:hashemgamal,项目名称:OSClass,代码行数:101,代码来源:settings.php

示例9: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             switch (Params::getParam('bulk_actions')) {
                 case 'activate_all':
                     $id = Params::getParam('id');
                     $value = 'ACTIVE';
                     try {
                         if ($id) {
                             foreach ($id as $_id) {
                                 $this->itemManager->update(array('e_status' => $value), array('pk_i_id' => $_id));
                                 $item = $this->itemManager->findByPrimaryKey($_id);
                                 CategoryStats::newInstance()->increaseNumItems($item['fk_i_category_id']);
                             }
                         }
                         osc_add_flash_message(_m('The items have been activated'), 'admin');
                     } catch (Exception $e) {
                         osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
                     }
                     break;
                 case 'deactivate_all':
                     $id = Params::getParam('id');
                     $value = 'INACTIVE';
                     try {
                         if ($id) {
                             foreach ($id as $_id) {
                                 $this->itemManager->update(array('e_status' => $value), array('pk_i_id' => $_id));
                                 $item = $this->itemManager->findByPrimaryKey($_id);
                                 CategoryStats::newInstance()->decreaseNumItems($item['fk_i_category_id']);
                             }
                         }
                         osc_add_flash_message(_m('The items have been deactivated'), 'admin');
                     } catch (Exception $e) {
                         osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
                     }
                     break;
                 case 'premium_all':
                     $id = Params::getParam('id');
                     $value = 1;
                     try {
                         if ($id) {
                             foreach ($id as $_id) {
                                 $this->itemManager->update(array('b_premium' => $value), array('pk_i_id' => $_id));
                             }
                         }
                         osc_add_flash_message(_m('The items have been marked as premium'), 'admin');
                     } catch (Exception $e) {
                         osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
                     }
                     break;
                 case 'depremium_all':
                     $id = Params::getParam('id');
                     $value = 0;
                     try {
                         if ($id) {
                             foreach ($id as $_id) {
                                 $this->itemManager->update(array('b_premium' => $value), array('pk_i_id' => $_id));
                             }
                         }
                         osc_add_flash_message(_m('The changes have been made'), 'admin');
                     } catch (Exception $e) {
                         osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
                     }
                     break;
                 case 'delete_all':
                     $id = Params::getParam('id');
                     $success = false;
                     foreach ($id as $i) {
                         if ($i) {
                             $item = $this->itemManager->findByPrimaryKey($i);
                             $mItems = new ItemActions(true);
                             $success = $mItems->delete($item['s_secret'], $item['pk_i_id']);
                         }
                     }
                     if ($success) {
                         osc_add_flash_message(_m('The item has been deleted'), 'admin');
                     } else {
                         osc_add_flash_message(_m('The item couldn\'t be deleted'), 'admin');
                     }
                     $this->redirectTo(osc_admin_base_url(true) . "?page=items");
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . "?page=items");
             break;
         case 'delete':
             //delete
             $id = Params::getParam('id');
             $success = false;
             foreach ($id as $i) {
                 if ($i) {
                     $item = $this->itemManager->findByPrimaryKey($i);
                     $mItems = new ItemActions(true);
                     $success = $mItems->delete($item['s_secret'], $item['pk_i_id']);
                 }
             }
             if ($success) {
                 osc_add_flash_message(_m('The item has been deleted'), 'admin');
//.........这里部分代码省略.........
开发者ID:hashemgamal,项目名称:OSClass,代码行数:101,代码来源:items.php


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