Ejemplo n.º 1
0
 /**
  * Create nested material of structure
  * @param $name
  * @param $url
  * @return \samson\activerecord\material
  */
 public function createNestedMaterial($name, $url)
 {
     $material = new \samson\activerecord\material(false);
     $material->Name = $name;
     $material->Url = $url;
     $material->system = 1;
     $material->Active = 1;
     $material->save();
     return $material;
 }
Ejemplo n.º 2
0
 public function createMaterial()
 {
     $material = new \samson\activerecord\material(false);
     $material->Name = $this->Name . ' - material';
     $material->Active = 1;
     $material->Url = generate_password(10);
     $material->Published = 0;
     $material->save();
     /** @var CMSNav $seoNav */
     $seoNav = null;
     if (dbQuery('structure')->cond('Url', '__seo')->first($seoNav)) {
         $strmat = new \samson\activerecord\structurematerial(false);
         $strmat->MaterialID = $material->id;
         $strmat->StructureID = $seoNav->id;
         $strmat->Active = 1;
         $strmat->save();
     }
     return $material->id;
 }
Ejemplo n.º 3
0
 /**
  * Generic material table object parser
  *
  * @param string $name Material unique identifier
  * @param null   $url
  * @param int    $published
  * @param int    $active
  * @param int    $user_id
  *
  * @see \samson\parse\ColumnParser::parser()
  * @return \samson\activerecord\material Material table object
  */
 public function &parser($name, $data, $url = null, $published = 1, $active = 1, $user_id = null)
 {
     $m = null;
     if ($this->allowEmptyValues || !isset($this->uniques[$name])) {
         $this->uniques[$name] = '';
         $inArrayValue = isset($this->findByField['index']) ? $data[$this->findByField['index']] : $name;
         if (!in_array($inArrayValue, $this->uniqueArray)) {
             $m = new \samson\activerecord\material(false);
             $m->Name = $name;
             $m->Url = $this->url_prefix . utf8_translit($name);
             $m->Published = $published;
             $m->Active = $active;
             $m->UserID = !isset($user_id) ? Excel2::$user->id : $user_id;
             $m->save();
         } elseif (!empty($this->findByField)) {
             $m = dbQuery('material')->cond($this->findByField['value'], $data[$this->findByField['index']])->first();
             if (!$m) {
                 $m = new \samson\activerecord\material(false);
             }
             $m->Name = $name;
             $m->Url = $this->url_prefix . utf8_translit($name);
             $m->Published = $published;
             $m->Active = $active;
             $m->UserID = !isset($user_id) ? Excel2::$user->id : $user_id;
             $m->save();
         }
     } else {
         // Trigger duplicate warning
         //e('Found duplicate material by ## at ##', D_SAMSON_DEBUG, array($value, $row_idx));
     }
     return $m;
 }