Exemplo n.º 1
0
 /**
  * Update widget info
  */
 protected final function updateInfoAllWidget()
 {
     $allWidget = get_child_folder(APP_DIR . '/widgets/frontend/');
     ZTranslate::getInstance()->addWidgetLang($allWidget, 'frontend');
     $this->deleteOldWidget($allWidget);
     foreach ($allWidget as $w) {
         $widgetPath = APP_DIR . '/widgets/frontend/' . $w . '/' . $w . '.php';
         $infoWidget = get_widget_data($widgetPath);
         $infoWidget['title'] = $infoWidget['name'];
         $widget = CoreWidgets::findFirst(['conditions' => 'base_name = ?0', 'bind' => [0 => $w]]);
         if (!$widget) {
             $widget = new CoreWidgets();
             $widget->base_name = $w;
             $widget->published = 0;
             $widget->is_core = 0;
         }
         $keys = ['title', 'description', 'version', 'author', 'uri', 'authorUri', 'location'];
         foreach ($keys as $key) {
             $widget->{$key} = $infoWidget[$key];
         }
         if (isset($widget->location) && (strtolower($widget->location) == 'frontend' || strtolower($widget->location) == 'backend')) {
             $widget->location = strtolower($widget->location);
         } else {
             $widget->location = 'frontend';
         }
         $widget->save();
     }
 }