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


PHP OSCLocale类代码示例

本文整理汇总了PHP中OSCLocale的典型用法代码示例。如果您正苦于以下问题:PHP OSCLocale类的具体用法?PHP OSCLocale怎么用?PHP OSCLocale使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: osc_checkLocales

function osc_checkLocales()
{
    $locales = osc_listLocales();
    foreach ($locales as $locale) {
        $data = OSCLocale::newInstance()->findByPrimaryKey($locale['code']);
        if (!is_array($data)) {
            $values = array('pk_c_code' => $locale['code'], 's_name' => $locale['name'], 's_short_name' => $locale['short_name'], 's_description' => $locale['description'], 's_version' => $locale['version'], 's_author_name' => $locale['author_name'], 's_author_url' => $locale['author_url'], 's_currency_format' => $locale['currency_format'], 's_date_format' => $locale['date_format'], 's_stop_words' => $locale['stop_words'], 'b_enabled' => 0, 'b_enabled_bo' => 1);
            $result = OSCLocale::newInstance()->insert($values);
            if (!$result) {
                return false;
            }
            // if it's a demo, we don't import any sql
            if (defined('DEMO')) {
                return true;
            }
            // inserting e-mail translations
            $path = sprintf('%s%s/mail.sql', osc_translations_path(), $locale['code']);
            if (file_exists($path)) {
                $sql = file_get_contents($path);
                $conn = DBConnectionClass::newInstance();
                $c_db = $conn->getOsclassDb();
                $comm = new DBCommandClass($c_db);
                $result = $comm->importSQL($sql);
                if (!$result) {
                    return false;
                }
            }
        } else {
            // update language version
            OSCLocale::newInstance()->update(array('s_version' => $locale['version']), array('pk_c_code' => $locale['code']));
        }
    }
    return true;
}
开发者ID:oanav,项目名称:closetshare,代码行数:34,代码来源:locales.php

示例2: getLocale

 /**
  * Return all locales enabled.
  * 
  * Call OSClocale
  * function listAllEnabled($isBo = false, $indexedByPk = false)
  * 
  * @url GET /locale
  * @url GET /locale/$code
  */
 public function getLocale($code)
 {
     if ($code) {
         $result = OSCLocale::newInstance()->findByCode($code);
     } else {
         $result = OSCLocale::newInstance()->listAllEnabled();
     }
     return $result;
 }
开发者ID:xop32,项目名称:aRestAPI4Osclass,代码行数:18,代码来源:apiServer.php

示例3: osc_checkLocales

function osc_checkLocales()
{
    $locales = osc_listLocales();
    foreach ($locales as $locale) {
        $data = OSCLocale::newInstance()->findByPrimaryKey($locale['code']);
        if (!is_array($data)) {
            OSCLocale::newInstance()->insert(array('pk_c_code' => $locale['code'], 's_name' => $locale['name'], 's_short_name' => $locale['short_name'], 's_description' => $locale['description'], 's_version' => $locale['version'], 's_author_name' => $locale['author_name'], 's_author_url' => $locale['author_url'], 's_currency_format' => $locale['currency_format'], 's_date_format' => $locale['date_format'], 's_stop_words' => $locale['stop_words'], 'b_enabled' => 0, 'b_enabled_bo' => 1));
        }
    }
}
开发者ID:hashemgamal,项目名称:OSClass,代码行数:10,代码来源:locales.php

示例4: init

 public function init()
 {
     $data = array_map(function ($v) {
         return array("s_internal_name" => $v["s_internal_name"], "locales" => array_map(function ($k, $v) {
             return array("fk_c_locale_code" => $k, "s_title" => $v["s_title"], "s_excerpt" => "", "s_text" => $v["s_text"]);
         }, array_keys($v["locale"]), array_values($v["locale"])));
     }, $this->model->listAll(true));
     View::newInstance()->_exportVariableToView("datas", json_encode(array("emails" => $data, "footer" => array("locales" => array_map(function ($v) {
         return array("fk_c_locale_code" => $v["pk_c_code"], "s_text" => "");
     }, OSCLocale::newInstance()->listAll()))), JSON_PRETTY_PRINT));
 }
开发者ID:bomvendador,项目名称:soroka_r,代码行数:11,代码来源:Admin.php

示例5: osc_checkLocales

function osc_checkLocales()
{
    $locales = osc_listLocales();
    foreach ($locales as $locale) {
        $data = OSCLocale::newInstance()->findByPrimaryKey($locale['code']);
        if (!is_array($data)) {
            OSCLocale::newInstance()->insert(array('pk_c_code' => $locale['code'], 's_name' => $locale['name'], 's_short_name' => $locale['short_name'], 's_description' => $locale['description'], 's_version' => $locale['version'], 's_author_name' => $locale['author_name'], 's_author_url' => $locale['author_url'], 's_currency_format' => $locale['currency_format'], 's_date_format' => $locale['date_format'], 's_stop_words' => $locale['stop_words'], 'b_enabled' => 0, 'b_enabled_bo' => 1));
            // inserting e-mail translations
            if (defined('DEMO')) {
                return true;
            }
            $path = sprintf('%s%s/mail.sql', osc_translations_path(), $locale['code']);
            if (file_exists($path)) {
                $sql = file_get_contents($path);
                $conn = getConnection();
                $conn->osc_dbImportSQL($sql);
            }
        }
    }
}
开发者ID:nsswaga,项目名称:OSClass,代码行数:20,代码来源:locales.php

示例6: _osc_check_languages_update

function _osc_check_languages_update()
{
    $total = 0;
    $array = array();
    $array_downloaded = array();
    $languages = OSCLocale::newInstance()->listAll();
    foreach ($languages as $lang) {
        if (osc_check_language_update($lang['pk_c_code'], $lang['s_version'])) {
            $array[] = $lang['pk_c_code'];
            $total++;
        }
        $array_downloaded[] = $lang['pk_c_code'];
    }
    osc_set_preference('languages_to_update', json_encode($array));
    osc_set_preference('languages_downloaded', json_encode($array_downloaded));
    osc_set_preference('languages_update_count', $total);
    osc_set_preference('languages_last_version_check', time());
    osc_reset_preferences();
    return $total;
}
开发者ID:oanav,项目名称:closetshare,代码行数:20,代码来源:functions.php

示例7: osc_check_languages_update

function osc_check_languages_update( $force = false )
{
    $total = 0;
    $array = array();
    $array_downloaded = array();
    // check if exist a new version each day
    if( (time() - osc_languages_last_version_check()) > (24 * 3600) || $force ) {
        $languages  = OSCLocale::newInstance()->listAll();
        foreach($languages as $lang) {
            if(osc_check_language_update($lang['pk_c_code'], $lang['s_version'] )) {
                $array[] = $lang['pk_c_code'];
                $total++;
            }
            $array_downloaded[] = $lang['pk_c_code'];
        }
        osc_set_preference( 'languages_to_update' , json_encode($array) );
        osc_set_preference( 'languages_downloaded', json_encode($array_downloaded) );
        osc_set_preference( 'languages_update_count', $total );
        osc_set_preference( 'languages_last_version_check', time() );
        osc_reset_preferences();
    } else {
        $total = getPreference('languages_update_count');
    }

    return $total;
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:26,代码来源:functions.php

示例8: oc_install


//.........这里部分代码省略.........
                return array('error' => __('Cannot connect to the database. Check if the user has privileges.'));
                break;
            case 1044:
                return array('error' => __('Cannot connect to the database. Check if the username and password are correct.'));
                break;
            case 2005:
                return array('error' => __('Cannot resolve MySQL host. Check if the host is correct.'));
                break;
            default:
                return array('error' => sprintf(__('Cannot connect to the database. Error number: %s'), $error_num));
                break;
        }
    }
    if (file_exists(ABS_PATH . 'config.php')) {
        if (!is_writable(ABS_PATH . 'config.php')) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__('Cannot write in config.php file. Check if the file is writable.'), __FILE__ . "::" . __LINE__);
            }
            return array('error' => __('Cannot write in config.php file. Check if the file is writable.'));
        }
        create_config_file($dbname, $username, $password, $dbhost, $tableprefix);
    } else {
        if (!file_exists(ABS_PATH . 'config-sample.php')) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__("config-sample.php doesn't exist. Check if you have everything well decompressed."), __FILE__ . "::" . __LINE__);
            }
            return array('error' => __("config-sample.php doesn't exist. Check if you have everything well decompressed."));
        }
        if (!is_writable(ABS_PATH)) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(__('Can\'t copy config-sample.php. Check if the root directory is writable.'), __FILE__ . "::" . __LINE__);
            }
            return array('error' => __('Can\'t copy config-sample.php. Check if the root directory is writable.'));
        }
        copy_config_file($dbname, $username, $password, $dbhost, $tableprefix);
    }
    require_once ABS_PATH . 'config.php';
    $sql = file_get_contents(ABS_PATH . 'oc-includes/osclass/installer/struct.sql');
    $c_db = $conn->getOsclassDb();
    $comm = new DBCommandClass($c_db);
    $comm->importSQL($sql);
    $error_num = $comm->getErrorLevel();
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error(sprintf(__('Cannot create the database structure. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
        }
        switch ($error_num) {
            case 1050:
                return array('error' => __('There are tables with the same name in the database. Change the table prefix or the database and try again.'));
                break;
            default:
                return array('error' => sprintf(__('Cannot create the database structure. Error number: %s'), $error_num));
                break;
        }
    }
    require_once LIB_PATH . 'osclass/model/OSCLocale.php';
    $localeManager = OSCLocale::newInstance();
    $locales = osc_listLocales();
    $values = array('pk_c_code' => $locales[osc_current_admin_locale()]['code'], 's_name' => $locales[osc_current_admin_locale()]['name'], 's_short_name' => $locales[osc_current_admin_locale()]['short_name'], 's_description' => $locales[osc_current_admin_locale()]['description'], 's_version' => $locales[osc_current_admin_locale()]['version'], 's_author_name' => $locales[osc_current_admin_locale()]['author_name'], 's_author_url' => $locales[osc_current_admin_locale()]['author_url'], 's_currency_format' => $locales[osc_current_admin_locale()]['currency_format'], 's_date_format' => $locales[osc_current_admin_locale()]['date_format'], 'b_enabled' => 1, 'b_enabled_bo' => 1);
    if (isset($locales[osc_current_admin_locale()]['stop_words'])) {
        $values['s_stop_words'] = $locales[osc_current_admin_locale()]['stop_words'];
    }
    $localeManager->insert($values);
    $required_files = array(ABS_PATH . 'oc-includes/osclass/installer/basic_data.sql', ABS_PATH . 'oc-includes/osclass/installer/pages.sql', ABS_PATH . 'oc-content/languages/' . osc_current_admin_locale() . '/mail.sql');
    $sql = '';
    foreach ($required_files as $file) {
        if (!file_exists($file)) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error(sprintf(__('The file %s doesn\'t exist'), $file), __FILE__ . "::" . __LINE__);
            }
            return array('error' => sprintf(__('The file %s doesn\'t exist'), $file));
        } else {
            $sql .= file_get_contents($file);
        }
    }
    $comm->importSQL($sql);
    $error_num = $comm->getErrorLevel();
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error(sprintf(__('Cannot insert basic configuration. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__);
        }
        switch ($error_num) {
            case 1471:
                return array('error' => __('Cannot insert basic configuration. This user has no privileges to \'INSERT\' into the database.'));
                break;
            default:
                return array('error' => sprintf(__('Cannot insert basic configuration. Error number: '), $error_num));
                break;
        }
    }
    osc_set_preference('language', osc_current_admin_locale());
    osc_set_preference('admin_language', osc_current_admin_locale());
    oc_install_example_data();
    if (reportToOsclass()) {
        set_allow_report_osclass(true);
    } else {
        set_allow_report_osclass(false);
    }
    return false;
}
开发者ID:randomecho,项目名称:OSClass,代码行数:101,代码来源:install-functions.php

示例9: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'create':
             // calling create view
             $aRegions = array();
             $aCities = array();
             $aCountries = Country::newInstance()->listAll();
             if (isset($aCountries[0]['pk_c_code'])) {
                 $aRegions = Region::newInstance()->findByCountry($aCountries[0]['pk_c_code']);
             }
             if (isset($aRegions[0]['pk_i_id'])) {
                 $aCities = City::newInstance()->findByRegion($aRegions[0]['pk_i_id']);
             }
             $this->_exportVariableToView('user', null);
             $this->_exportVariableToView('countries', $aCountries);
             $this->_exportVariableToView('regions', $aRegions);
             $this->_exportVariableToView('cities', $aCities);
             $this->_exportVariableToView('locales', OSCLocale::newInstance()->listAllEnabled());
             $this->doView("users/frm.php");
             break;
         case 'create_post':
             // creating the user...
             osc_csrf_check();
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(true);
             $success = $userActions->add();
             switch ($success) {
                 case 1:
                     osc_add_flash_ok_message(_m("The user has been created. We've sent an activation e-mail"), 'admin');
                     break;
                 case 2:
                     osc_add_flash_ok_message(_m('The user has been created successfully'), 'admin');
                     break;
                 default:
                     osc_add_flash_error_message($success, 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=users');
             break;
         case 'edit':
             // calling the edit view
             $aUser = $this->userManager->findByPrimaryKey(Params::getParam("id"));
             $aCountries = Country::newInstance()->listAll();
             $aRegions = array();
             if ($aUser['fk_c_country_code'] != '') {
                 $aRegions = Region::newInstance()->findByCountry($aUser['fk_c_country_code']);
             } else {
                 if (count($aCountries) > 0) {
                     $aRegions = Region::newInstance()->findByCountry($aCountries[0]['pk_c_code']);
                 }
             }
             $aCities = array();
             if ($aUser['fk_i_region_id'] != '') {
                 $aCities = City::newInstance()->findByRegion($aUser['fk_i_region_id']);
             } else {
                 if (count($aRegions) > 0) {
                     $aCities = City::newInstance()->findByRegion($aRegions[0]['pk_i_id']);
                 }
             }
             $csrf_token = osc_csrf_token_url();
             if ($aUser['b_active']) {
                 $actions[] = '<a class="btn float-left" href="' . osc_admin_base_url(true) . '?page=users&action=deactivate&id[]=' . $aUser['pk_i_id'] . '&' . $csrf_token . '&value=INACTIVE">' . __('Deactivate') . '</a>';
             } else {
                 $actions[] = '<a class="btn btn-red float-left" href="' . osc_admin_base_url(true) . '?page=users&action=activate&id[]=' . $aUser['pk_i_id'] . '&' . $csrf_token . '&value=ACTIVE">' . __('Activate') . '</a>';
             }
             if ($aUser['b_enabled']) {
                 $actions[] = '<a class="btn float-left" href="' . osc_admin_base_url(true) . '?page=users&action=disable&id[]=' . $aUser['pk_i_id'] . '&' . $csrf_token . '&value=DISABLE">' . __('Block') . '</a>';
             } else {
                 $actions[] = '<a class="btn btn-red float-left" href="' . osc_admin_base_url(true) . '?page=users&action=enable&id[]=' . $aUser['pk_i_id'] . '&' . $csrf_token . '&value=ENABLE">' . __('Unblock') . '</a>';
             }
             $this->_exportVariableToView("actions", $actions);
             $this->_exportVariableToView("user", $aUser);
             $this->_exportVariableToView("countries", $aCountries);
             $this->_exportVariableToView("regions", $aRegions);
             $this->_exportVariableToView("cities", $aCities);
             $this->_exportVariableToView("locales", OSCLocale::newInstance()->listAllEnabled());
             $this->doView("users/frm.php");
             break;
         case 'edit_post':
             // edit post
             osc_csrf_check();
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(true);
             $success = $userActions->edit(Params::getParam("id"));
             if ($success == 1) {
                 osc_add_flash_ok_message(_m('The user has been updated'), 'admin');
             } else {
                 if ($success == 2) {
                     osc_add_flash_ok_message(_m('The user has been updated and activated'), 'admin');
                 } else {
                     osc_add_flash_error_message($success);
                     $this->redirectTo(osc_admin_base_url(true) . '?page=users&action=edit&id=' . Params::getParam('id'));
                 }
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=users');
             break;
         case 'resend_activation':
//.........这里部分代码省略.........
开发者ID:naneri,项目名称:Osclass,代码行数:101,代码来源:users.php

示例10: doModel

 function doModel()
 {
     //calling the view...
     $locales = OSCLocale::newInstance()->listAllEnabled();
     $this->_exportVariableToView('locales', $locales);
     switch ($this->action) {
         case 'item_add':
             // post
             if (osc_reg_user_post() && $this->user == null) {
                 osc_add_flash_warning_message(_m('Only registered users are allowed to post listings'));
                 $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()->findByCountry($this->user['fk_c_country_code']);
             } else {
                 if (count($countries) > 0) {
                     $regions = Region::newInstance()->findByCountry($countries[0]['pk_c_code']);
                 }
             }
             $cities = array();
             if (isset($this->user['fk_i_region_id']) && $this->user['fk_i_region_id'] != '') {
                 $cities = City::newInstance()->findByRegion($this->user['fk_i_region_id']);
             } else {
                 if (count($regions) > 0) {
                     $cities = City::newInstance()->findByRegion($regions[0]['pk_i_id']);
                 }
             }
             $this->_exportVariableToView('countries', $countries);
             $this->_exportVariableToView('regions', $regions);
             $this->_exportVariableToView('cities', $cities);
             $form = count(Session::newInstance()->_getForm());
             $keepForm = count(Session::newInstance()->_getKeepForm());
             if ($form == 0 || $form == $keepForm) {
                 Session::newInstance()->_dropKeepForm();
             }
             if (Session::newInstance()->_getForm('countryId') != "") {
                 $countryId = Session::newInstance()->_getForm('countryId');
                 $regions = Region::newInstance()->findByCountry($countryId);
                 $this->_exportVariableToView('regions', $regions);
                 if (Session::newInstance()->_getForm('regionId') != "") {
                     $regionId = Session::newInstance()->_getForm('regionId');
                     $cities = City::newInstance()->findByRegion($regionId);
                     $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_reg_user_post() && $this->user == null) {
                 osc_add_flash_warning_message(_m('Only registered users are allowed to post listings'));
                 $this->redirectTo(osc_base_url(true));
             }
             $mItems = new ItemActions(false);
             // prepare data for ADD ITEM
             $mItems->prepareData(true);
             // set all parameters into session
             foreach ($mItems->data as $key => $value) {
                 Session::newInstance()->_setForm($key, $value);
             }
             $meta = Params::getParam('meta');
             if (is_array($meta)) {
                 foreach ($meta as $key => $value) {
                     Session::newInstance()->_setForm('meta_' . $key, $value);
                     Session::newInstance()->_keepForm('meta_' . $key);
                 }
             }
             if (osc_recaptcha_private_key() != '' && Params::existParam("recaptcha_challenge_field")) {
                 if (!osc_check_recaptcha()) {
                     osc_add_flash_error_message(_m('The Recaptcha code is wrong'));
                     $this->redirectTo(osc_item_post_url());
                     return false;
                     // BREAK THE PROCESS, THE RECAPTCHA IS WRONG
                 }
             }
             if (!osc_is_web_user_logged_in()) {
                 $user = User::newInstance()->findByEmail($mItems->data['contactEmail']);
                 // The user exists but it's not logged
                 if (isset($user['pk_i_id'])) {
                     foreach ($mItems->data as $key => $value) {
                         Session::newInstance()->_keepForm($key);
                     }
                     osc_add_flash_error_message(_m('A user with that email address already exists, if it is you, please log in'));
                     $this->redirectTo(osc_user_login_url());
                 }
             }
             // POST ITEM ( ADD ITEM )
             $success = $mItems->add();
             if ($success != 1 && $success != 2) {
                 osc_add_flash_error_message($success);
                 $this->redirectTo(osc_item_post_url());
             } else {
                 Session::newInstance()->_dropkeepForm('meta_' . $key);
                 if ($success == 1) {
                     osc_add_flash_ok_message(_m('Check your inbox to validate your listing'));
                 } else {
//.........这里部分代码省略.........
开发者ID:semul,项目名称:Osclass,代码行数:101,代码来源:item.php

示例11: fn_email_item_validation_non_register_user

function fn_email_item_validation_non_register_user($item)
{
    View::newInstance()->_exportVariableToView('item', $item);
    $mPages = new Page();
    $aPage = $mPages->findByInternalName('email_item_validation_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_url = osc_item_url();
    $item_url = '<a href="' . $item_url . '" >' . $item_url . '</a>';
    $edit_url = osc_item_edit_url($item['s_secret'], $item['pk_i_id']);
    $delete_url = osc_item_delete_url($item['s_secret'], $item['pk_i_id']);
    $all = '';
    if (isset($item['locale'])) {
        foreach ($item['locale'] as $locale => $data) {
            $locale_name = OSCLocale::newInstance()->listWhere("pk_c_code = '" . $locale . "'");
            $all .= '<br/>';
            if (isset($locale_name[0]) && isset($locale_name[0]['s_name'])) {
                $all .= __('Language') . ': ' . $locale_name[0]['s_name'] . '<br/>';
            } else {
                $all .= __('Language') . ': ' . $locale . '<br/>';
            }
            $all .= __('Title') . ': ' . $data['s_title'] . '<br/>';
            $all .= __('Description') . ': ' . $data['s_description'] . '<br/>';
            $all .= '<br/>';
        }
    } else {
        $all .= __('Title') . ': ' . $item['s_title'] . '<br/>';
        $all .= __('Description') . ': ' . $item['s_description'] . '<br/>';
    }
    // Format activation URL
    $validation_url = osc_item_activate_url($item['s_secret'], $item['pk_i_id']);
    $words = array();
    $words[] = array('{ITEM_DESCRIPTION_ALL_LANGUAGES}', '{ITEM_DESCRIPTION}', '{ITEM_COUNTRY}', '{ITEM_PRICE}', '{ITEM_REGION}', '{ITEM_CITY}', '{ITEM_ID}', '{USER_NAME}', '{USER_EMAIL}', '{WEB_URL}', '{ITEM_TITLE}', '{ITEM_URL}', '{WEB_TITLE}', '{VALIDATION_LINK}', '{VALIDATION_URL}', '{EDIT_LINK}', '{EDIT_URL}', '{DELETE_LINK}', '{DELETE_URL}');
    $words[] = array($all, $item['s_description'], $item['s_country'], osc_prepare_price($item['s_price']), $item['s_region'], $item['s_city'], $item['pk_i_id'], $item['s_contact_name'], $item['s_contact_email'], '<a href="' . osc_base_url() . '" >' . osc_base_url() . '</a>', $item['s_title'], $item_url, osc_page_title(), '<a href="' . $validation_url . '" >' . $validation_url . '</a>', $validation_url, '<a href="' . $edit_url . '">' . $edit_url . '</a>', $edit_url, '<a href="' . $delete_url . '">' . $delete_url . '</a>', $delete_url);
    $title = osc_mailBeauty(osc_apply_filter('email_title', osc_apply_filter('email_item_validation_non_register_user_title', $content['s_title'])), $words);
    $body = osc_mailBeauty(osc_apply_filter('email_description', osc_apply_filter('email_item_validation_non_register_user_description', $content['s_text'])), $words);
    $emailParams = array('subject' => $title, 'to' => $item['s_contact_email'], 'to_name' => $item['s_contact_name'], 'body' => $body, 'alt_body' => $body);
    osc_sendMail($emailParams);
}
开发者ID:nsswaga,项目名称:OSClass,代码行数:44,代码来源:emails.php

示例12: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'create':
             // callign create view
             $aCountries = array();
             $aRegions = array();
             $aCities = array();
             $aCountries = Country::newInstance()->listAll();
             if (isset($aCountries[0]['pk_c_code'])) {
                 $aRegions = Region::newInstance()->getByCountry($aCountries[0]['pk_c_code']);
             }
             if (isset($aRegions[0]['pk_i_id'])) {
                 $aCities = City::newInstance()->listWhere("fk_i_region_id = %d", $aRegions[0]['pk_i_id']);
             }
             $this->_exportVariableToView("user", null);
             $this->_exportVariableToView("countries", $aCountries);
             $this->_exportVariableToView("regions", $aRegions);
             $this->_exportVariableToView("cities", $aCities);
             $this->_exportVariableToView("locales", OSCLocale::newInstance()->listAllEnabled());
             $this->doView("users/frm.php");
             break;
         case 'create_post':
             // creating the user...
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(true);
             $success = $userActions->add();
             switch ($success) {
                 case 1:
                     osc_add_flash_message(_m('The user has been created. We\'ve sent an activation e-mail'), 'admin');
                     break;
                 case 2:
                     osc_add_flash_message(_m('The user has been created and activated'), 'admin');
                     break;
                 case 3:
                     osc_add_flash_message(_m('Sorry, but that e-mail is already in use'), 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=users');
             break;
         case 'edit':
             // calling the edit view
             $aUser = array();
             $aCountries = array();
             $aRegions = array();
             $aCities = array();
             $aUser = $this->userManager->findByPrimaryKey(Params::getParam("id"));
             $aCountries = Country::newInstance()->listAll();
             $aRegions = array();
             if ($aUser['fk_c_country_code'] != '') {
                 $aRegions = Region::newInstance()->getByCountry($aUser['fk_c_country_code']);
             } else {
                 if (count($aCountries) > 0) {
                     $aRegions = Region::newInstance()->getByCountry($aCountries[0]['pk_c_code']);
                 }
             }
             $aCities = array();
             if ($aUser['fk_i_region_id'] != '') {
                 $aCities = City::newInstance()->listWhere("fk_i_region_id = %d", $aUser['fk_i_region_id']);
             } else {
                 if (count($aRegions) > 0) {
                     $aCities = City::newInstance()->listWhere("fk_i_region_id = %d", $aRegions[0]['pk_i_id']);
                 }
             }
             $this->_exportVariableToView("user", $aUser);
             $this->_exportVariableToView("countries", $aCountries);
             $this->_exportVariableToView("regions", $aRegions);
             $this->_exportVariableToView("cities", $aCities);
             $this->_exportVariableToView("locales", OSCLocale::newInstance()->listAllEnabled());
             $this->doView("users/frm.php");
             break;
         case 'edit_post':
             // edit post
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(true);
             $success = $userActions->edit(Params::getParam("id"));
             switch ($success) {
                 case 1:
                     osc_add_flash_message(_m('Passwords don\'t match'), 'admin');
                     break;
                 case 2:
                     osc_add_flash_message(_m('The user has been updated and activated'), 'admin');
                     break;
                 default:
                     osc_add_flash_message(_m('The user has been updated'), 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=users');
             break;
         case 'activate':
             //activate
             $iUpdated = 0;
             $userId = Params::getParam('id');
             if (!is_array($userId)) {
                 osc_add_flash_message(_m('User id isn\'t in the correct format'), 'admin');
             }
             foreach ($userId as $id) {
                 $conditions = array('pk_i_id' => $id);
//.........这里部分代码省略.........
开发者ID:hashemgamal,项目名称:OSClass,代码行数:101,代码来源:users.php

示例13: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'add':
             $this->_exportVariableToView("categories", $this->categoryManager->toTreeAll());
             $this->_exportVariableToView("languages", OSCLocale::newInstance()->listAllEnabled());
             $this->_exportVariableToView("category", array());
             $this->doView("categories/frm.php");
             break;
         case 'add_post':
             try {
                 // fields contain data of t_category
                 $fields['fk_i_parent_id'] = Params::getParam("fk_i_parent_id") != '' ? Params::getParam("fk_i_parent_id") : null;
                 $fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
                 $fields['i_position'] = Params::getParam("i_position") != '' ? Params::getParam("i_position") : 0;
                 $fields['b_enabled'] = Params::getParam("b_enabled") != '' ? 1 : 0;
                 $postParams = Params::getParamsAsArray();
                 foreach ($postParams as $k => $v) {
                     if (preg_match('|(.+?)#(.+)|', $k, $m)) {
                         $aFieldsDescription[$m[1]][$m[2]] = $v;
                     }
                 }
                 $this->categoryManager->insert($fields, $aFieldsDescription);
                 osc_add_flash_message(_m('The category has been added'), 'admin');
             } catch (Exception $e) {
                 osc_add_flash_message(_m('The category could\'t be added') . $e->getMessage(), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=categories');
             break;
         case 'edit':
             $this->_exportVariableToView("category", $this->categoryManager->findByPrimaryKey(Params::getParam("id")));
             $this->_exportVariableToView("categories", $this->categoryManager->toTreeAll());
             $this->_exportVariableToView("languages", OSCLocale::newInstance()->listAllEnabled());
             $this->doView("categories/frm.php");
             break;
         case 'edit_post':
             $id = Params::getParam("id");
             $fields['fk_i_parent_id'] = Params::getParam("fk_i_parent_id") != '' ? Params::getParam("fk_i_parent_id") : null;
             $fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
             $fields['i_position'] = Params::getParam("i_position") != '' ? Params::getParam("i_position") : 0;
             $fields['b_enabled'] = Params::getParam("b_enabled") != '' ? 1 : 0;
             $postParams = Params::getParamsAsArray();
             foreach ($postParams as $k => $v) {
                 if (preg_match('|(.+?)#(.+)|', $k, $m)) {
                     $aFieldsDescription[$m[1]][$m[2]] = $v;
                 }
             }
             try {
                 $this->categoryManager->updateByPrimaryKey($fields, $aFieldsDescription, $id);
                 osc_add_flash_message(_m('The category has been updated.'), 'admin');
             } catch (Exception $e) {
                 osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
             }
             if (!is_null($fields['fk_i_parent_id'])) {
                 $this->redirectTo(osc_admin_base_url(true) . '?page=categories&parentId=' . $fields['fk_i_parent_id']);
             } else {
                 $this->redirectTo(osc_admin_base_url(true) . '?page=categories');
             }
             break;
         case 'delete':
             $id = Params::getParam("id");
             try {
                 foreach ($id as $i) {
                     if (intval($i)) {
                         $this->categoryManager->deleteByPrimaryKey($i);
                     }
                 }
                 osc_add_flash_message(_m('The categories have been deleted'), 'admin');
             } catch (Exception $e) {
                 osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=categories');
             break;
         case 'enable':
             $id = Params::getParam("id");
             $enabled = Params::getParam("enabled") != '' ? Params::getParam("enabled") : 0;
             try {
                 if ($id != '') {
                     $this->categoryManager->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
                     if ($enabled == 1) {
                         $msg = _m('The category has been enabled');
                     } else {
                         $msg = _m('The category has been disabled');
                     }
                 } else {
                     $msg = _m('There was a problem with this page. The ID for the category hasn\'t been set');
                 }
                 osc_add_flash_message($msg, 'admin');
             } catch (Exception $e) {
                 osc_add_flash_message(_m('Error: ') . $e->getMessage(), 'admin');
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=categories');
             break;
         case 'enable_selected':
             $ids = Params::getParam("id");
             try {
                 if ($ids != '') {
                     foreach ($ids as $id) {
//.........这里部分代码省略.........
开发者ID:hashemgamal,项目名称:OSClass,代码行数:101,代码来源:categories.php

示例14: 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');
             $order = array();
             $error = 0;
             $catManager = Category::newInstance();
             $aRecountCat = array();
             foreach ($aIds as $cat) {
                 if (!isset($order[$cat['p']])) {
                     $order[$cat['p']] = 0;
                 }
                 $res = $catManager->update(array('fk_i_parent_id' => $cat['p'] == 'root' ? NULL : $cat['p'], 'i_position' => $order[$cat['p']]), array('pk_i_id' => $cat['c']));
                 if (is_bool($res) && !$res) {
                     $error = 1;
                 } else {
                     if ($res == 1) {
                         $aRecountCat[] = $cat['c'];
                     }
                 }
                 $order[$cat['p']] = $order[$cat['p']] + 1;
             }
             // update category stats
             foreach ($aRecountCat as $rId) {
                 osc_update_cat_stats_id($rId);
             }
             if ($error) {
                 $result = array('error' => __("An error occurred"));
             } else {
                 $result = array('ok' => __("Order saved"));
             }
             echo json_encode($result);
             break;
         case 'category_edit_iframe':
             $this->_exportVariableToView('category', Category::newInstance()->findByPrimaryKey(Params::getParam("id"), 'all'));
             if (count(Category::newInstance()->findSubcategories(Params::getParam("id"))) > 0) {
                 $this->_exportVariableToView('has_subcategories', true);
             } else {
                 $this->_exportVariableToView('has_subcategories', false);
             }
             $this->_exportVariableToView('languages', OSCLocale::newInstance()->listAllEnabled());
             $this->doView("categories/iframe.php");
             break;
         case 'field_categories_iframe':
             $selected = Field::newInstance()->categories(Params::getParam("id"));
             if ($selected == null) {
//.........这里部分代码省略.........
开发者ID:adrienrn,项目名称:Osclass,代码行数:101,代码来源:ajax.php

示例15: doModel

 function doModel()
 {
     parent::doModel();
     //specific things for this class
     switch ($this->action) {
         case 'create':
             // callign create view
             $aCountries = array();
             $aRegions = array();
             $aCities = array();
             $aCountries = Country::newInstance()->listAll();
             if (isset($aCountries[0]['pk_c_code'])) {
                 $aRegions = Region::newInstance()->findByCountry($aCountries[0]['pk_c_code']);
             }
             if (isset($aRegions[0]['pk_i_id'])) {
                 $aCities = City::newInstance()->findByRegion($aRegions[0]['pk_i_id']);
             }
             $this->_exportVariableToView('user', null);
             $this->_exportVariableToView('countries', $aCountries);
             $this->_exportVariableToView('regions', $aRegions);
             $this->_exportVariableToView('cities', $aCities);
             $this->_exportVariableToView('locales', OSCLocale::newInstance()->listAllEnabled());
             $this->doView("users/frm.php");
             break;
         case 'create_post':
             // creating the user...
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(true);
             $success = $userActions->add();
             switch ($success) {
                 case 1:
                     osc_add_flash_ok_message(_m('The user has been created. We\'ve sent an activation e-mail'), 'admin');
                     break;
                 case 2:
                     osc_add_flash_ok_message(_m('The user has been created successfully'), 'admin');
                     break;
                 case 3:
                     osc_add_flash_warning_message(_m('Sorry, but that e-mail is already in use'), 'admin');
                     break;
                 case 5:
                     osc_add_flash_warning_message(_m('The specified e-mail is not valid'), 'admin');
                     break;
                 case 6:
                     osc_add_flash_warning_message(_m('Sorry, the password cannot be empty'), 'admin');
                     break;
                 case 7:
                     osc_add_flash_warning_message(_m("Sorry, passwords don't match"), 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=users');
             break;
         case 'edit':
             // calling the edit view
             $aUser = array();
             $aCountries = array();
             $aRegions = array();
             $aCities = array();
             $aUser = $this->userManager->findByPrimaryKey(Params::getParam("id"));
             $aCountries = Country::newInstance()->listAll();
             $aRegions = array();
             if ($aUser['fk_c_country_code'] != '') {
                 $aRegions = Region::newInstance()->findByCountry($aUser['fk_c_country_code']);
             } else {
                 if (count($aCountries) > 0) {
                     $aRegions = Region::newInstance()->findByCountry($aCountries[0]['pk_c_code']);
                 }
             }
             $aCities = array();
             if ($aUser['fk_i_region_id'] != '') {
                 $aCities = City::newInstance()->findByRegion($aUser['fk_i_region_id']);
             } else {
                 if (count($aRegions) > 0) {
                     $aCities = City::newInstance()->findByRegion($aRegions[0]['pk_i_id']);
                 }
             }
             $this->_exportVariableToView("user", $aUser);
             $this->_exportVariableToView("countries", $aCountries);
             $this->_exportVariableToView("regions", $aRegions);
             $this->_exportVariableToView("cities", $aCities);
             $this->_exportVariableToView("locales", OSCLocale::newInstance()->listAllEnabled());
             $this->doView("users/frm.php");
             break;
         case 'edit_post':
             // edit post
             require_once LIB_PATH . 'osclass/UserActions.php';
             $userActions = new UserActions(true);
             $success = $userActions->edit(Params::getParam("id"));
             switch ($success) {
                 case 1:
                     osc_add_flash_error_message(_m('Passwords don\'t match'), 'admin');
                     break;
                 case 2:
                     osc_add_flash_ok_message(_m('The user has been updated and activated'), 'admin');
                     break;
                 default:
                     osc_add_flash_ok_message(_m('The user has been updated'), 'admin');
                     break;
             }
             $this->redirectTo(osc_admin_base_url(true) . '?page=users');
             break;
//.........这里部分代码省略.........
开发者ID:acharei,项目名称:OSClass,代码行数:101,代码来源:users.php


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