Ejemplo n.º 1
0
 public function indexAction()
 {
     $this->name = $this->p('category', Setting_Category::first()->name);
     $this->current = Setting_Category::get($this->name);
     $this->settings = Setting::getCategory($this->name);
     $this->pageTitle = 'Settings: ' . $this->current->title;
 }
Ejemplo n.º 2
0
 public function field(Setting $setting)
 {
     $category = Setting_Category::getById($setting->setting_category_id);
     $name = $this->fieldName($category, $setting);
     $helper = $setting->type . 'Field';
     return $this->{$helper}($setting, $name, $this->get($category->name, $setting->name));
 }
Ejemplo n.º 3
0
 /**
  * @depends testAppendCategory
  */
 public function testOrder()
 {
     $this->testAppendCategory();
     $cache = Setting_Category::all();
     $i = 0;
     foreach ($cache as $name => $category) {
         self::assertEquals($this->names[$i], $name);
         ++$i;
     }
 }
Ejemplo n.º 4
0
 /**
  * @return void
  * @param Nano_Db $db
  */
 public function run(Nano_Db $db)
 {
     Setting_Category::append('core', 'Core settings');
     Setting::append('core', 'string', 'version', 'Core version', null, '1.0.0');
     Setting::append('core', 'bool', 'enabled', 'Enable core', null, '0');
     Setting_Category::append('application', 'Application settings');
     Setting::append('application', 'string', 'name', 'Application name');
     Setting::append('application', 'text', 'desc', 'Application description');
     Setting::append('application', 'html', 'footer', 'Application footer text');
     Setting_Category::append('email', 'E-Mail settings');
     Setting::append('email', 'string', 'admin', 'Administrator e-mail addres');
 }
Ejemplo n.º 5
0
 protected function setUp()
 {
     $this->invalidateCaches();
     Nano::db()->delete(Setting_Category::NAME);
     Setting_Category::append('some', 'some category');
 }
Ejemplo n.º 6
0
 protected static function invalidate()
 {
     self::$cache = null;
 }
Ejemplo n.º 7
0
 protected static function loadCache()
 {
     $result = array();
     $query = sql::select('s.*')->from(array('s' => self::NAME))->innerJoin(array('c' => Setting_Category::NAME), 's.setting_category_id = c.setting_category_id')->order('c.' . self::db()->quoteName('order'))->order('s.' . self::db()->quoteName('order'));
     $rows = self::fetchThis($query);
     foreach ($rows as $row) {
         $category = Setting_Category::getById($row->setting_category_id)->name;
         if (isset($result[$category])) {
             $result[$category][$row->name] = $row;
         } else {
             $result[$category] = array($row->name => $row);
         }
     }
     return $result;
 }