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


PHP Field::newInstance方法代码示例

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


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

示例1: theme_install

 function theme_install()
 {
     $categories = osc_get_categories();
     $categories_ids = array();
     addSubCategoories($categories, $categories_ids);
     if (!osc_get_preference('keyword_placeholder', 'seeker')) {
         osc_set_preference('keyword_placeholder', __('ie. PHP Programmer'), 'seeker');
     }
     if (!Field::newInstance()->findBySlug('s_department')) {
         Field::newInstance()->insertField(__('Department or Unit', 'seeker'), 'TEXT', 's_department', 0, '', $categories_ids);
     }
     if (!Field::newInstance()->findBySlug('s_position_type')) {
         Field::newInstance()->insertField(__('Employment Type', 'seeker'), 'DROPDOWN', 's_position_type', 0, __('Full Time', 'seeker') . ',' . __('Part Time', 'seeker') . ',' . __('Part Time to Full Time', 'seeker') . ',' . __('Temporary', 'seeker') . ',' . __('Temporary to Full Time', 'seeker') . ',' . __('Full Time', 'seeker') . ',' . __('Contracted', 'seeker') . ',' . __('Contracted to Full Time', 'seeker') . ',' . __('Internship', 'seeker') . ',' . __('Internship to Full Time', 'seeker') . ',' . __('Seasonal', 'seeker') . ',' . __('Volunteer', 'seeker'), $categories_ids);
     }
     if (!Field::newInstance()->findBySlug('s_job_experience')) {
         Field::newInstance()->insertField(__('Minimum Experience', 'seeker'), 'DROPDOWN', 's_job_experience', 0, __('Student (High School)', 'seeker') . ',' . __('Student (College)', 'seeker') . ',' . __('Entry Level', 'seeker') . ',' . __('Mid Level', 'seeker') . ',' . __('Experienced', 'seeker') . ',' . __('Manager/Supervisor', 'seeker') . ',' . __('Senior Manager/Supervisor', 'seeker') . ',' . __('Executive', 'seeker') . ',' . __('Senior Executive'), $categories_ids);
     }
     if (!Field::newInstance()->findBySlug('s_number_positions')) {
         Field::newInstance()->insertField(__('Number of positions', 'seeker'), 'TEXT', 's_number_positions', 0, '', $categories_ids);
     }
     if (!Field::newInstance()->findBySlug('s_salary')) {
         Field::newInstance()->insertField(__('Salary', 'seeker'), 'TEXT', 's_salary', 0, '', $categories_ids);
     }
     $version = theme_version_info();
     //Save that theme has installed
     osc_set_preference($version['name'], $version['version'], 'seeker');
 }
开发者ID:ricktaylord,项目名称:osclass-themes,代码行数:27,代码来源:functions.php

示例2: 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, osc_max_characters_per_title()) ) {
                    $td_message = '';
                    break;
                }

                $td_message .=
                    (!osc_validate_text($value, 1) ? _m("Title too short.") . PHP_EOL : '' ) .
                    (!osc_validate_max($value, osc_max_characters_per_title()) ? _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, osc_max_characters_per_description()) )  {
                    $desc_message = '';
                    break;
                }

                $desc_message .=
                    (!osc_validate_text($value, 3) ? _m("Description too short.") . PHP_EOL : '' ) .
                    (!osc_validate_max($value, osc_max_characters_per_description()) ? _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(number_format($aItem['price'],0,'',''), 15)) ? _m("Price too long.") . PHP_EOL : '' ) .
                ((!is_null($aItem['price']) && (int)$aItem['price']<0 ) ? _m('Price must be positive number.') . 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'], 2, false)) ? _m("Region too short.") . PHP_EOL : '' ) .
                ((!osc_validate_max($aItem['regionName'], 50)) ? _m("Region too long.") . PHP_EOL : '' ) .
                ((!osc_validate_text($aItem['cityName'], 2, 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']) . PHP_EOL;
                        }
                    }
                }
            };

            // hook pre add or edit
            // DEPRECATED : preitem_psot will be removed in 3.4
            osc_run_hook('pre_item_post');
            osc_run_hook('pre_item_edit', $aItem);

            // Handle error
            if ($flash_error) {
                $success = $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'],
                    'd_coord_lat'       => $aItem['d_coord_lat'],
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:101,代码来源:ItemActions.php

示例3: meta_fields_input

 public static function meta_fields_input($catId = null, $itemId = null)
 {
     $fields = Field::newInstance()->findByCategoryItem($catId, $itemId);
     if (count($fields) > 0) {
         echo '<div class="meta_list">';
         foreach ($fields as $field) {
             echo '<div class="meta">';
             FieldForm::meta($field);
             echo '</div>';
         }
         echo '</div>';
     }
 }
开发者ID:jmcclenon,项目名称:Osclass,代码行数:13,代码来源:Field.form.class.php

示例4: doModel


//.........这里部分代码省略.........
         } else {
             $p_sRegion = explode(",", $p_sRegion);
         }
     }
     $p_sCountry = Params::getParam('sCountry');
     if (!is_array($p_sCountry)) {
         if ($p_sCountry == '') {
             $p_sCountry = array();
         } else {
             $p_sCountry = explode(",", $p_sCountry);
         }
     }
     $p_sUser = Params::getParam('sUser');
     if (!is_array($p_sUser)) {
         if ($p_sUser == '') {
             $p_sUser = '';
         } else {
             $p_sUser = explode(",", $p_sUser);
         }
     }
     $p_sLocale = Params::getParam('sLocale');
     if (!is_array($p_sLocale)) {
         if ($p_sLocale == '') {
             $p_sLocale = '';
         } else {
             $p_sLocale = explode(",", $p_sLocale);
         }
     }
     $p_sPattern = trim(strip_tags(Params::getParam('sPattern')));
     // ADD TO THE LIST OF LAST SEARCHES
     if (osc_save_latest_searches() && (!Params::existParam('iPage') || Params::getParam('iPage') == 1)) {
         $savePattern = osc_apply_filter('save_latest_searches_pattern', $p_sPattern);
         if ($savePattern != '') {
             LatestSearches::newInstance()->insert(array('s_search' => $savePattern, 'd_date' => date('Y-m-d H:i:s')));
         }
     }
     $p_bPic = Params::getParam('bPic');
     $p_bPic = $p_bPic == 1 ? 1 : 0;
     $p_bPremium = Params::getParam('bPremium');
     $p_bPremium = $p_bPremium == 1 ? 1 : 0;
     $p_sPriceMin = Params::getParam('sPriceMin');
     $p_sPriceMax = Params::getParam('sPriceMax');
     //WE CAN ONLY USE THE FIELDS RETURNED BY Search::getAllowedColumnsForSorting()
     $p_sOrder = Params::getParam('sOrder');
     if (!in_array($p_sOrder, Search::getAllowedColumnsForSorting())) {
         $p_sOrder = osc_default_order_field_at_search();
     }
     $old_order = $p_sOrder;
     //ONLY 0 ( => 'asc' ), 1 ( => 'desc' ) AS ALLOWED VALUES
     $p_iOrderType = Params::getParam('iOrderType');
     $allowedTypesForSorting = Search::getAllowedTypesForSorting();
     $orderType = osc_default_order_type_at_search();
     foreach ($allowedTypesForSorting as $k => $v) {
         if ($p_iOrderType == $v) {
             $orderType = $k;
             break;
         }
     }
     $p_iOrderType = $orderType;
     $p_sFeed = Params::getParam('sFeed');
     $p_iPage = 0;
     if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') > 0) {
         $p_iPage = intval(Params::getParam('iPage')) - 1;
     }
     if ($p_sFeed != '') {
         $p_sPageSize = 1000;
开发者ID:mylastof,项目名称:os-class,代码行数:67,代码来源:search.php

示例5: 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

示例6: __construct

 function __construct()
 {
     parent::__construct();
     //specific things for this class
     $this->fieldManager = Field::newInstance();
 }
开发者ID:acharei,项目名称:OSClass,代码行数:6,代码来源:custom_fields.php

示例7: 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(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 'items':
             // Return items (use external file oc-admin/ajax/item_processing.php)
             require_once osc_admin_base_path() . 'ajax/items_processing.php';
             $items_processing = new ItemsProcessingAjax(Params::getParamsAsArray("get"));
             break;
         case 'users':
             // Return items (use external file oc-admin/ajax/item_processing.php)
             require_once osc_admin_base_path() . 'ajax/users_processing.php';
             $users_processing = new UsersProcessingAjax(Params::getParamsAsArray("get"));
             break;
         case 'media':
             // Return items (use external file oc-admin/ajax/media_processing.php)
             require_once osc_admin_base_path() . 'ajax/media_processing.php';
             $media_processing = new MediaProcessingAjax(Params::getParamsAsArray("get"));
             break;
         case 'categories_order':
             // Save the order of the categories
             $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);
//.........这里部分代码省略.........
开发者ID:ricktaylord,项目名称:OSClass,代码行数:101,代码来源:ajax.php

示例8: edit

 function edit()
 {
     $aItem = $this->data;
     $flash_error = '';
     // Initiate HTML Purifier
     require_once LIB_PATH . 'htmlpurifier/HTMLPurifier.auto.php';
     $config = HTMLPurifier_Config::createDefault();
     $config->set('HTML.Allowed', 'b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style]');
     $config->set('CSS.AllowedProperties', 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align');
     $config->set('Cache.SerializerPath', ABS_PATH . 'oc-content/uploads');
     $purifier = new HTMLPurifier($config);
     // Sanitize
     foreach (@$aItem['title'] as $key => $value) {
         $aItem['title'][$key] = strip_tags(trim($value));
     }
     foreach (@$aItem['description'] as $key => $value) {
         $aItem['description'][$key] = $purifier->purify($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 incorrect extension.") . PHP_EOL;
     }
     if (!$this->checkSize($aItem['photos'])) {
         $flash_error .= _m("Images 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 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 = Params::getParam("meta");
     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();
         $locationManager->update($location, array('fk_i_item_id' => $aItem['idItem']));
         // Update category numbers
         $old_item = $this->manager->findByPrimaryKey($aItem['idItem']);
         if ($old_item['fk_i_category_id'] != $aItem['catId']) {
             CategoryStats::newInstance()->increaseNumItems($aItem['catId']);
             CategoryStats::newInstance()->decreaseNumItems($old_item['fk_i_category_id']);
         }
         unset($old_item);
         $result = $this->manager->update(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']), 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);
             }
         }
         osc_run_hook('item_edit_post', $aItem['catId'], $aItem['idItem']);
         return 1;
     }
     return 0;
 }
开发者ID:acharei,项目名称:OSClass,代码行数:96,代码来源:ItemActions.php

示例9: osc_get_item_meta

 *            the License, or (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful, but
 *         WITHOUT ANY WARRANTY; without even the implied warranty of
 *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *             GNU Affero General Public License for more details.
 *
 *      You should have received a copy of the GNU Affero General Public
 * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
//Fields
$fields = osc_get_item_meta();
$fields_by_slug = array();
$fields_by_name = array();
foreach ($fields as $field) {
    $field_details = Field::newInstance()->findByPrimaryKey($field['pk_i_id']);
    $fields_by_slug[$field_details['s_slug']] = $field;
    $fields_by_name[] = $field_details['s_name'];
}
?>
<div id="main">
    <div id="item_head">
        <div class="inner">
            <h1><strong><?php 
echo osc_item_title();
?>
</strong></h1>
            <?php 
if ($fields_by_slug['s_department']['s_value'] != '') {
    ?>
<h2><?php 
开发者ID:ricktaylord,项目名称:osclass-themes,代码行数:31,代码来源:inc.item.main.php

示例10: 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

示例11: 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()->getByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->getByRegion(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 'alerts':
             // Allow to register to an alert given (not sure it's used on admin)
             $alert = Params::getParam("alert");
             $email = Params::getParam("email");
             $userid = Params::getParam("userid");
             if ($alert != '' && $email != '') {
                 Alerts::newInstance()->insert(array('fk_i_user_id' => $userid, 's_email' => $email, 's_search' => $alert, 'e_type' => 'DAILY'));
                 echo "1";
                 return true;
             }
             echo '0';
             break;
         case 'runhook':
             //Run hooks
             $hook = Params::getParam("hook");
             switch ($hook) {
                 case 'item_form':
                     $catId = Params::getParam("catId");
                     if ($catId != '') {
                         osc_run_hook("item_form", $catId);
                     } else {
                         osc_run_hook("item_form");
                     }
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     if ($hook == '') {
                         return false;
                     } else {
                         osc_run_hook($hook);
                     }
                     break;
             }
             break;
         case 'items':
             // Return items (use external file oc-admin/ajax/item_processing.php)
             require_once osc_admin_base_path() . 'ajax/items_processing.php';
             $items_processing = new items_processing_ajax(Params::getParamsAsArray("get"));
             break;
         case 'media':
             // Return items (use external file oc-admin/ajax/media_processing.php)
             require_once osc_admin_base_path() . 'ajax/media_processing.php';
             $media_processing = new media_processing_ajax(Params::getParamsAsArray("get"));
             break;
         case 'categories_order':
             // Save the order of the categories
             $aIds = Params::getParam('list');
             $orderParent = 0;
             $orderSub = 0;
             $catParent = 0;
             $catManager = Category::newInstance();
             foreach ($aIds as $id => $parent) {
                 if ($parent == 'root') {
                     if (!$catManager->update_order($id, $orderParent)) {
                         $error = 1;
                     }
                     // set parent category
                     $conditions = array('pk_i_id' => $id);
                     $array['fk_i_parent_id'] = DB_CONST_NULL;
                     if (!$catManager->update($array, $conditions) > 0) {
                         $error = 1;
                     }
                     $orderParent++;
                 } else {
                     if ($parent != $catParent) {
                         $catParent = $parent;
                         $orderSub = 0;
                     }
                     if (!$catManager->update_order($id, $orderSub)) {
                         $error = 1;
                     }
                     // set parent category
                     $conditions = array('pk_i_id' => $id);
                     $array['fk_i_parent_id'] = $catParent;
                     if (!$catManager->update($array, $conditions) > 0) {
//.........这里部分代码省略.........
开发者ID:nsswaga,项目名称:OSClass,代码行数:101,代码来源:ajax.php

示例12: adimporter_ad

function adimporter_ad($listing, $cat_info, $meta_info)
{
    $mItems = new ItemActions(true);
    $catId = @$listing->getElementsByTagName("categoryid")->item(0)->nodeValue;
    Params::setParam("country", @$listing->getElementsByTagName("country")->item(0)->nodeValue);
    Params::setParam("countryId", @$listing->getElementsByTagName("countryId")->item(0)->nodeValue);
    Params::setParam("region", @$listing->getElementsByTagName("region")->item(0)->nodeValue);
    Params::setParam("city", @$listing->getElementsByTagName("city")->item(0)->nodeValue);
    Params::setParam("cityArea", @$listing->getElementsByTagName("city_area")->item(0)->nodeValue);
    Params::setParam("address", @$listing->getElementsByTagName("address")->item(0)->nodeValue);
    Params::setParam("price", @$listing->getElementsByTagName("price")->item(0)->nodeValue);
    Params::setParam("currency", @$listing->getElementsByTagName("currency")->item(0)->nodeValue);
    Params::setParam("contactName", @$listing->getElementsByTagName("contactname")->item(0)->nodeValue);
    Params::setParam("contactEmail", @$listing->getElementsByTagName("contactemail")->item(0)->nodeValue);
    if ($catId == null) {
        $cats = $listing->getElementsByTagName("category");
        $cat_insert = true;
        $catId = 0;
        if ($cats->length > 0) {
            foreach ($cats as $cat) {
                $lang = osc_language();
                if ($cat->hasAttributes()) {
                    $attrs = $cat->attributes;
                    foreach ($attrs as $a) {
                        if ($a->name == 'lang') {
                            $lang = $a->value;
                            break;
                        }
                    }
                    $categoryDescription[$lang] = array('s_name' => $cat->nodeValue);
                    if ($catId == 0) {
                        if (isset($cat_info[$lang]) && isset($meta_info[$lang][$cat->nodeValue])) {
                            $catId = $cat_info[$lang][$cat->nodeValue];
                        } else {
                            $exists = Category::newInstance()->listWhere("b.fk_c_locale_code = '" . $lang . "' AND b.s_name = '" . $cat->nodeValue . "'");
                            if (isset($exists[0]) && isset($exists[0]['pk_i_id'])) {
                                $cat_info[$lang][$cat->nodeValue] = $exists[0]['pk_i_id'];
                                $cat_insert = false;
                                $catId = $exists[0]['pk_i_id'];
                                break;
                            }
                        }
                    }
                }
            }
            $category = array();
            $category['fk_i_parent_id'] = NULL;
            $category['i_expiration_days'] = 0;
            $category['i_position'] = 0;
            $category['b_enabled'] = 1;
            if ($cat_insert) {
                $catId = Category::newInstance()->insert($category, $categoryDescription);
            }
        }
    }
    Params::setParam("catId", $catId);
    $title_list = $listing->getElementsByTagName("title");
    $content_list = $listing->getElementsByTagName("content");
    $image_list = $listing->getElementsByTagName("image");
    $custom_list = $listing->getElementsByTagName("custom");
    $title = array();
    $content = array();
    $photos = '';
    $l = $title_list->length;
    for ($k = 0; $k < $l; $k++) {
        $lang = osc_language();
        if ($title_list->item($k)->hasAttributes()) {
            $attrs = $title_list->item($k)->attributes;
            foreach ($attrs as $a) {
                if ($a->name == 'lang') {
                    $lang = $a->value;
                    break;
                }
            }
        }
        $title[$lang] = $title_list->item($k)->nodeValue;
    }
    $l = $content_list->length;
    for ($k = 0; $k < $l; $k++) {
        $lang = osc_language();
        if ($content_list->item($k)->hasAttributes()) {
            $attrs = $content_list->item($k)->attributes;
            foreach ($attrs as $a) {
                if ($a->name == 'lang') {
                    $lang = $a->value;
                    break;
                }
            }
        }
        $content[$lang] = $content_list->item($k)->nodeValue;
    }
    $meta_array = array();
    $l = $custom_list->length;
    for ($k = 0; $k < $l; $k++) {
        if ($custom_list->item($k)->hasAttributes()) {
            $attrs = $custom_list->item($k)->attributes;
            foreach ($attrs as $a) {
                if ($a->name == 'name') {
                    $field_name = $a->value;
                    if (isset($meta_info[$field_name])) {
//.........这里部分代码省略.........
开发者ID:michaelxizhou,项目名称:myeden69-original-backup,代码行数:101,代码来源:index.php


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