Jump to content

Help with default values in array


seabastion

Recommended Posts

Hello,

 

In the following function, I want to define default values for 'i18n'. I believe it is an array, it shows in another file defined as:

 

                public $i18n = array('title', 'description', 'terms', 'confirm_tokens', 'confirm_subject',

                                'payment_tokens', 'payment_subject', 'meta_title', 'meta_keywords', 'meta_description');

 

 

So I would need to set default values of i18n to 'text1', 'text 2', 'text 3', ... in the function below.

 

Could you help?

 

Thanks

 

 

 

 

                                $this->checkLogin();

                               

                                if ($this->isAdmin() || $this->isEditor() || $this->isOwner())

                                {

                                                if (isset($_POST['listing_create']))

                                                {

                                                                $data = array();

                                                                if (isset($_POST['expire']))

                                                                {

                                                                                $data['expire'] = pjUtil::formatDate($_POST['expire'], $this->option_arr['o_date_format']);

                                                                }

                                                                $data['last_extend'] = 'free';

                                                                if ($this->isOwner())

                                                                {

                                                                                $data['owner_id'] = $this->getUserId();

                                                                                $data['status'] = 'E';

                                                                                $data['is_featured'] = 'F';

                                                                                $data['expire'] = date("Y-m-d", strtotime("-1 day"));

                                                                }

                                                                $data = array_merge($_POST, $data);

                                                                $pjListingModel = pjListingModel::factory();

                                                                if (!$pjListingModel->validates($data))

                                                                {

                                                                                pjUtil::redirect($_SERVER['PHP_SELF'] . "?controller=pjAdminListings&action=pjActionCreate&err=1");

                                                                }

                                                               

                                                                if ($pjListingModel->where('t1.listing_refid', $data['listing_refid'])->findCount()->getData() > 0)

                                                                {

                                                                                pjUtil::redirect($_SERVER['PHP_SELF'] . "?controller=pjAdminListings&action=pjActionCreate&err=1");

                                                                }

                                                               

                                                                //$data = pjSanitize::clean($data);

                                                                $id = $pjListingModel->reset()->setAttributes($data)->insert()->getInsertId();

                                                                if ($id !== false && (int) $id > 0)

                                                                {

                                                                                $err = 'AC03';

                                                                                if (isset($_POST['i18n']))

                                                                                {

                                                                                                pjMultiLangModel::factory()->saveMultiLang($_POST['i18n'], $id, 'pjListing');

                                                                                }

                                                                                $this->notify(2, NULL, array('property_id' => $id, 'listing_refid' => $data['listing_refid']));

                                                                } else {

                                                                                $err = 'AC04';

                                                                }

                                                               

                                                                if ($id !== false && (int) $id > 0)

                                                                {

                                                                                pjUtil::redirect($_SERVER['PHP_SELF'] . "?controller=pjAdminListings&action=pjActionUpdate&id=" . $id);

                                                                } else {

                                                                                pjUtil::redirect($_SERVER['PHP_SELF'] . "?controller=pjAdminListings&action=pjActionCreate&err=1");

                                                                }

                                                }

                                               

                                                if ($this->isOwner())

                                                {

                                                                $this->set('period_arr', pjPeriodModel::factory()->orderBy('t1.days ASC')->findAll()->getData());

                                                }

 

                                                $type_arr = pjTypeModel::factory()->select('t1.*, t2.content AS name')

                                                                ->join('pjMultiLang', "t2.model='pjType' AND t2.foreign_id=t1.id AND t2.field='name' AND t2.locale='".$this->getLocaleId()."'")

                                                                ->where('t1.status', 'T')->orderBy('name ASC')->findAll()->getData();

                                                $this->set('type_arr', pjSanitize::clean($type_arr));

 

                                                $user_arr = pjUserModel::factory()->orderBy('t1.name ASC')->findAll()->getData();

                                                $this->set('user_arr', pjSanitize::clean($user_arr));

                                                               

                                                $this->appendJs('chosen.jquery.js', PJ_THIRD_PARTY_PATH . 'harvest/chosen/');

                                                $this->appendCss('chosen.css', PJ_THIRD_PARTY_PATH . 'harvest/chosen/');

                                                               

                                                $this->appendJs('jquery.tipsy.js', PJ_THIRD_PARTY_PATH . 'tipsy/');

                                                $this->appendCss('jquery.tipsy.css', PJ_THIRD_PARTY_PATH . 'tipsy/');

                                                               

                                                $this->appendJs('jquery.validate.min.js', PJ_THIRD_PARTY_PATH . 'validate/');

                                                $this->appendJs('pjAdminListings.js');

                                } else {

                                                $this->set('status', 2);

                                }

Link to comment
https://forums.phpfreaks.com/topic/282488-help-with-default-values-in-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.