/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Prefix();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Prefix'])) {
         //            $model->attributes=$_POST['Prefix'];
         $model->prefix = $_POST['Prefix']['prefix'];
         $model->url = $_POST['Prefix']['url'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemplo n.º 2
0
 public function save($id = null)
 {
     if ($_POST) {
         $data = new Prefix($id);
         if ($_POST['id'] == '') {
             $_POST['created_by'] = $this->user->id;
         } else {
             $_POST['updated_by'] = $this->user->id;
         }
         $data->from_array($_POST);
         $data->save();
         $action = @$_POST['id'] > 0 ? 'UPDATE' : 'CREATE';
         save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->org_name . ' Prefixes ');
     }
     redirect("admin/settings/prefixes");
 }
Exemplo n.º 3
0
 public static function populatePrefixes($xhtml)
 {
     $c = new Criteria();
     $prefixes = self::doSelect($c);
     foreach ($xhtml->body->ol->li as $value) {
         $uri = (string) $value['content'];
         $prefix = (string) $value->a;
         $rank = (int) $value->span['content'];
         //lookup prefix by prefix
         $old = self::findByPrefix($prefix);
         if (!$old) {
             $old = new \Prefix();
             $old->setPrefix($prefix);
         }
         $old->setUri($uri);
         $old->setRank($rank);
         $old->save();
     }
     return $prefixes;
 }