widget() public static method

public static widget ( ) : self
return self
Esempio n. 1
0
 /**
  * Insert the templates.
  */
 private function insertTemplates()
 {
     /*
      * Fallback templates
      */
     // build templates
     $templates['core']['default'] = array('theme' => 'core', 'label' => 'Default', 'path' => 'Core/Layout/Templates/Default.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[main]', 'names' => array('main'))));
     $templates['core']['home'] = array('theme' => 'core', 'label' => 'Home', 'path' => 'Core/Layout/Templates/Home.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[main]', 'names' => array('main'))));
     // insert templates
     $this->getDB()->insert('themes_templates', $templates['core']['default']);
     $this->getDB()->insert('themes_templates', $templates['core']['home']);
     /*
      * Triton templates
      */
     // search will be installed by default; already link it to this template
     $extras['search_form'] = $this->insertExtra('search', ModuleExtraType::widget(), 'SearchForm', 'form', null, 'N', 2001);
     // build templates
     $templates['triton']['default'] = array('theme' => 'triton', 'label' => 'Default', 'path' => 'Core/Layout/Templates/Default.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[/,advertisement,advertisement,advertisement],[/,/,top,top],[/,/,/,/],[left,main,main,main]', 'names' => array('main', 'left', 'top', 'advertisement'), 'default_extras' => array('top' => array($extras['search_form'])), 'image' => false)));
     $templates['triton']['home'] = array('theme' => 'triton', 'label' => 'Home', 'path' => 'Core/Layout/Templates/Home.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[/,advertisement,advertisement,advertisement],[/,/,top,top],[/,/,/,/],[main,main,main,main],[left,left,right,right]', 'names' => array('main', 'left', 'right', 'top', 'advertisement'), 'default_extras' => array('top' => array($extras['search_form'])), 'image' => true)));
     // insert templates
     $this->getDB()->insert('themes_templates', $templates['triton']['default']);
     $this->getDB()->insert('themes_templates', $templates['triton']['home']);
     /*
      * General theme settings
      */
     // set default theme
     $this->setSetting('Core', 'theme', 'triton', true);
     // set default template
     $this->setSetting('Pages', 'default_template', $this->getTemplateId('default'));
     // disable meta navigation
     $this->setSetting('Pages', 'meta_navigation', false);
 }
Esempio n. 2
0
 /**
  * Install the module
  */
 public function install()
 {
     // load install.sql
     $this->importSQL(__DIR__ . '/Data/install.sql');
     // add 'search' as a module
     $this->addModule('Search');
     // import locale
     $this->importLocale(__DIR__ . '/Data/locale.xml');
     // general settings
     $this->setSetting('Search', 'overview_num_items', 10);
     $this->setSetting('Search', 'validate_search', true);
     // module rights
     $this->setModuleRights(1, 'Search');
     // action rights
     $this->setActionRights(1, 'Search', 'AddSynonym');
     $this->setActionRights(1, 'Search', 'EditSynonym');
     $this->setActionRights(1, 'Search', 'DeleteSynonym');
     $this->setActionRights(1, 'Search', 'Settings');
     $this->setActionRights(1, 'Search', 'Statistics');
     $this->setActionRights(1, 'Search', 'Synonyms');
     // set navigation
     $navigationModulesId = $this->setNavigation(null, 'Modules');
     $navigationSearchId = $this->setNavigation($navigationModulesId, 'Search');
     $this->setNavigation($navigationSearchId, 'Statistics', 'search/statistics');
     $this->setNavigation($navigationSearchId, 'Synonyms', 'search/synonyms', array('search/add_synonym', 'search/edit_synonym'));
     // settings navigation
     $navigationSettingsId = $this->setNavigation(null, 'Settings');
     $navigationModulesId = $this->setNavigation($navigationSettingsId, 'Modules');
     $this->setNavigation($navigationModulesId, 'Search', 'search/settings');
     // add extra's
     $searchId = $this->insertExtra('Search', ModuleExtraType::block(), 'Search', null, null, 'N', 2000);
     $this->insertExtra('Search', ModuleExtraType::widget(), 'SearchForm', 'Form', null, 'N', 2001);
     // loop languages
     foreach ($this->getLanguages() as $language) {
         // check if a page for search already exists in this language
         // @todo refactor this nasty if statement...
         if (!(bool) $this->getDB()->getVar('SELECT 1
              FROM pages AS p
              INNER JOIN pages_blocks AS b ON b.revision_id = p.revision_id
              WHERE b.extra_id = ? AND p.language = ?
              LIMIT 1', array($searchId, $language))) {
             // insert search
             $this->insertPage(array('title' => \SpoonFilter::ucfirst($this->getLocale('Search', 'Core', $language, 'lbl', 'Frontend')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $searchId, 'position' => 'main'));
         }
     }
     // activate search on 'pages'
     $this->searchPages();
     // create module cache path
     $filesystem = new Filesystem();
     if (!$filesystem->exists(PATH_WWW . '/src/Frontend/Cache/Search')) {
         $filesystem->mkdir(PATH_WWW . '/src/Frontend/Cache/Search');
     }
 }
Esempio n. 3
0
 /**
  * Install the module
  */
 public function install()
 {
     // load install.sql
     $this->importSQL(__DIR__ . '/Data/install.sql');
     // add 'blog' as a module
     $this->addModule('Tags');
     // import locale
     $this->importLocale(__DIR__ . '/Data/locale.xml');
     // module rights
     $this->setModuleRights(1, 'Tags');
     // action rights
     $this->setActionRights(1, 'Tags', 'Autocomplete');
     $this->setActionRights(1, 'Tags', 'Edit');
     $this->setActionRights(1, 'Tags', 'Index');
     $this->setActionRights(1, 'Tags', 'MassAction');
     // set navigation
     $navigationModulesId = $this->setNavigation(null, 'Modules');
     $this->setNavigation($navigationModulesId, 'Tags', 'tags/index', array('tags/edit'));
     // add extra
     $tagsID = $this->insertExtra('Tags', ModuleExtraType::block(), 'Tags', null, null, 'N', 30);
     $this->insertExtra('Tags', ModuleExtraType::widget(), 'TagCloud', 'TagCloud', null, 'N', 31);
     $this->insertExtra('Tags', ModuleExtraType::widget(), 'Related', 'Related', null, 'N', 32);
     // get search extra id
     $searchId = (int) $this->getDB()->getVar('SELECT id FROM modules_extras WHERE module = ? AND type = ? AND action = ?', array('Search', ModuleExtraType::WIDGET, 'Form'));
     // loop languages
     foreach ($this->getLanguages() as $language) {
         // check if a page for tags already exists in this language
         // @todo refactor this if statement
         if (!(bool) $this->getDB()->getVar('SELECT 1
              FROM pages AS p
              INNER JOIN pages_blocks AS b ON b.revision_id = p.revision_id
              WHERE b.extra_id = ? AND p.language = ?
              LIMIT 1', array($tagsID, $language))) {
             // insert contact page
             $this->insertPage(array('title' => 'Tags', 'type' => 'root', 'language' => $language), null, array('extra_id' => $tagsID, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
         }
     }
 }
Esempio n. 4
0
 /**
  * Install the module
  */
 public function install()
 {
     // load install.sql
     $this->importSQL(__DIR__ . '/Data/install.sql');
     // add 'location' as a module
     $this->addModule('Location');
     // import locale
     $this->importLocale(__DIR__ . '/Data/locale.xml');
     // general settings
     $this->setSetting('Location', 'zoom_level', 'auto');
     $this->setSetting('Location', 'width', 400);
     $this->setSetting('Location', 'height', 300);
     $this->setSetting('Location', 'map_type', 'ROADMAP');
     $this->setSetting('Location', 'zoom_level_widget', 13);
     $this->setSetting('Location', 'width_widget', 400);
     $this->setSetting('Location', 'height_widget', 300);
     $this->setSetting('Location', 'map_type_widget', 'ROADMAP');
     $this->setSetting('Location', 'requires_google_maps', true);
     // module rights
     $this->setModuleRights(1, 'Location');
     // action rights
     $this->setActionRights(1, 'Location', 'Index');
     $this->setActionRights(1, 'Location', 'Add');
     $this->setActionRights(1, 'Location', 'Edit');
     $this->setActionRights(1, 'Location', 'Delete');
     $this->setActionRights(1, 'Location', 'SaveLiveLocation');
     $this->setActionRights(1, 'Location', 'UpdateMarker');
     // set navigation
     $navigationModulesId = $this->setNavigation(null, 'Modules');
     $this->setNavigation($navigationModulesId, 'Location', 'location/index', array('location/add', 'location/edit'));
     // settings navigation
     $navigationSettingsId = $this->setNavigation(null, 'Settings');
     $navigationModulesId = $this->setNavigation($navigationSettingsId, 'Modules');
     $this->setNavigation($navigationModulesId, 'Location', 'location/settings');
     // add extra's
     $this->insertExtra('Location', ModuleExtraType::widget(), 'Location', null, 'a:1:{s:3:"url";s:34:"/private/location/index?token=true";}', 'N');
 }
Esempio n. 5
0
 /**
  * Install example data
  */
 private function installExampleData()
 {
     // insert/get extra ids
     $extras['blog_block'] = $this->insertExtra('Blog', ModuleExtraType::block(), 'Blog', null, null, 'N', 1000);
     $extras['blog_widget_recent_comments'] = $this->insertExtra('Blog', ModuleExtraType::widget(), 'RecentComments', 'RecentComments', null, 'N', 1001);
     $extras['blog_widget_categories'] = $this->insertExtra('Blog', ModuleExtraType::widget(), 'Categories', 'Categories', null, 'N', 1002);
     $extras['blog_widget_archive'] = $this->insertExtra('Blog', ModuleExtraType::widget(), 'Archive', 'Archive', null, 'N', 1003);
     $extras['blog_widget_recent_articles_full'] = $this->insertExtra('Blog', ModuleExtraType::widget(), 'RecentArticlesFull', 'RecentArticlesFull', null, 'N', 1004);
     $extras['blog_widget_recent_articles_list'] = $this->insertExtra('Blog', ModuleExtraType::widget(), 'RecentArticlesList', 'RecentArticlesList', null, 'N', 1005);
     $extras['search'] = $this->insertExtra('Search', ModuleExtraType::block(), 'Search', null, null, 'N', 2000);
     $extras['search_form'] = $this->insertExtra('Search', ModuleExtraType::widget(), 'SearchForm', 'Form', null, 'N', 2001);
     $extras['sitemap_widget_sitemap'] = $this->insertExtra('Pages', ModuleExtraType::widget(), 'Sitemap', 'Sitemap', null, 'N', 1);
     $extras['subpages_widget'] = $this->insertExtra('Pages', ModuleExtraType::widget(), 'Subpages', 'Subpages', serialize(array('template' => 'SubpagesDefault.html.twig')), 'N', 2);
     // loop languages
     foreach ($this->getLanguages() as $language) {
         // check if pages already exist for this language
         if (!(bool) $this->getDB()->getVar('SELECT 1 FROM pages WHERE language = ? AND id > ? LIMIT 1', array($language, 404))) {
             // re-insert homepage
             $this->insertPage(array('id' => 1, 'parent_id' => 0, 'template_id' => $this->getTemplateId('home'), 'title' => \SpoonFilter::ucfirst($this->getLocale('Home', 'Core', $language, 'lbl', 'Backend')), 'language' => $language, 'allow_move' => 'N', 'allow_delete' => 'N'), null, array('html' => __DIR__ . '/Data/' . $language . '/sample1.txt'), array('extra_id' => $extras['blog_widget_recent_articles_list'], 'position' => 'left'), array('extra_id' => $extras['blog_widget_recent_comments'], 'position' => 'right'), array('extra_id' => $extras['search_form'], 'position' => 'top'));
             // blog
             $this->insertPage(array('title' => \SpoonFilter::ucfirst($this->getLocale('Blog', 'Core', $language, 'lbl', 'Frontend')), 'language' => $language), null, array('extra_id' => $extras['blog_block']), array('extra_id' => $extras['blog_widget_recent_comments'], 'position' => 'left'), array('extra_id' => $extras['blog_widget_categories'], 'position' => 'left'), array('extra_id' => $extras['blog_widget_archive'], 'position' => 'left'), array('extra_id' => $extras['blog_widget_recent_articles_list'], 'position' => 'left'), array('extra_id' => $extras['search_form'], 'position' => 'top'));
             // about us parent
             $aboutUsId = $this->insertPage(array('title' => \SpoonFilter::ucfirst($this->getLocale('AboutUs', 'Core', $language, 'lbl', 'Frontend')), 'parent_id' => 1, 'language' => $language), null, array('extra_id' => $extras['subpages_widget']), array('extra_id' => $extras['search_form'], 'position' => 'top'));
             // location
             $this->insertPage(array('title' => \SpoonFilter::ucfirst($this->getLocale('Location', 'Core', $language, 'lbl', 'Frontend')), 'parent_id' => $aboutUsId, 'language' => $language), null, array('html' => __DIR__ . '/Data/' . $language . '/sample1.txt'), array('html' => __DIR__ . '/Data/' . $language . '/sample2.txt'), array('extra_id' => $extras['search_form'], 'position' => 'top'));
             // about us child
             $this->insertPage(array('title' => \SpoonFilter::ucfirst($this->getLocale('AboutUs', 'Core', $language, 'lbl', 'Frontend')), 'parent_id' => $aboutUsId, 'language' => $language), null, array('html' => __DIR__ . '/Data/' . $language . '/sample1.txt'), array('html' => __DIR__ . '/Data/' . $language . '/sample2.txt'), array('extra_id' => $extras['search_form'], 'position' => 'top'));
             // history
             $this->insertPage(array('title' => \SpoonFilter::ucfirst($this->getLocale('History', 'Core', $language, 'lbl', 'Frontend')), 'parent_id' => 1, 'language' => $language), null, array('html' => __DIR__ . '/Data/' . $language . '/sample1.txt'), array('html' => __DIR__ . '/Data/' . $language . '/sample2.txt'), array('extra_id' => $extras['search_form'], 'position' => 'top'));
             // insert lorem ipsum test page
             $this->insertPage(array('title' => 'Lorem ipsum', 'type' => 'root', 'language' => $language, 'hidden' => 'Y'), array('data' => array('seo_index' => 'noindex', 'seo_follow' => 'nofollow')), array('html' => __DIR__ . '/Data/' . $language . '/lorem_ipsum.txt'), array('extra_id' => $extras['search_form'], 'position' => 'top'));
         }
     }
 }
Esempio n. 6
0
 /**
  * Add a new item.
  *
  * @param array $item The data to insert.
  *
  * @return int
  *
  * @deprecated use doctrine instead
  */
 public static function insert(array $item)
 {
     trigger_error('Backend\\Modules\\ContentBlocks\\Engine is deprecated.
          Switch to doctrine instead.', E_USER_DEPRECATED);
     // insert extra
     $item['extra_id'] = BackendModel::insertExtra(ModuleExtraType::widget(), 'ContentBlocks', 'Detail');
     $item['revision_id'] = BackendModel::get('database')->insert('content_blocks', $item);
     // update data for the extra
     BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('Edit', 'ContentBlocks', $item['language']) . '&id=' . $item['id'], 'custom_template' => $item['template']));
     return $item['revision_id'];
 }
Esempio n. 7
0
 /**
  * Add a new item.
  *
  * @param array $values The data to insert.
  *
  * @return int
  */
 public static function insert(array $values)
 {
     // define form id
     $formId = BackendModel::getContainer()->get('database')->insert('forms', $values);
     // insert extra
     BackendModel::insertExtra(ModuleExtraType::widget(), 'FormBuilder', 'Form', 'FormBuilder', array('id' => $formId, 'extra_label' => $values['name'], 'language' => $values['language'], 'edit_url' => BackendModel::createURLForAction('Edit') . '&id=' . $formId), false, '400' . $formId);
     return $formId;
 }
Esempio n. 8
0
 /**
  * Install the module
  */
 public function install()
 {
     // load install.sql
     $this->importSQL(__DIR__ . '/Data/install.sql');
     // add 'blog' as a module
     $this->addModule('Blog');
     // import locale
     $this->importLocale(__DIR__ . '/Data/locale.xml');
     // general settings
     $this->setSetting('Blog', 'allow_comments', true);
     $this->setSetting('Blog', 'requires_akismet', true);
     $this->setSetting('Blog', 'spamfilter', false);
     $this->setSetting('Blog', 'moderation', true);
     // @TODO remove this when the api is kicked out
     $this->setSetting('Blog', 'ping_services', false);
     $this->setSetting('Blog', 'overview_num_items', 10);
     $this->setSetting('Blog', 'recent_articles_full_num_items', 3);
     $this->setSetting('Blog', 'recent_articles_list_num_items', 5);
     $this->setSetting('Blog', 'max_num_revisions', 20);
     $this->makeSearchable('Blog');
     // module rights
     $this->setModuleRights(1, 'Blog');
     // action rights
     $this->setActionRights(1, 'Blog', 'AddCategory');
     $this->setActionRights(1, 'Blog', 'Add');
     $this->setActionRights(1, 'Blog', 'Categories');
     $this->setActionRights(1, 'Blog', 'Comments');
     $this->setActionRights(1, 'Blog', 'DeleteCategory');
     $this->setActionRights(1, 'Blog', 'DeleteSpam');
     $this->setActionRights(1, 'Blog', 'Delete');
     $this->setActionRights(1, 'Blog', 'EditCategory');
     $this->setActionRights(1, 'Blog', 'EditComment');
     $this->setActionRights(1, 'Blog', 'Edit');
     $this->setActionRights(1, 'Blog', 'ImportWordpress');
     $this->setActionRights(1, 'Blog', 'Index');
     $this->setActionRights(1, 'Blog', 'MassCommentAction');
     $this->setActionRights(1, 'Blog', 'Settings');
     // insert dashboard widget
     $this->insertWidget();
     // set navigation
     $navigationModulesId = $this->setNavigation(null, 'Modules');
     $navigationBlogId = $this->setNavigation($navigationModulesId, 'Blog');
     $this->setNavigation($navigationBlogId, 'Articles', 'blog/index', array('blog/add', 'blog/edit', 'blog/import_wordpress'));
     $this->setNavigation($navigationBlogId, 'Comments', 'blog/comments', array('blog/edit_comment'));
     $this->setNavigation($navigationBlogId, 'Categories', 'blog/categories', array('blog/add_category', 'blog/edit_category'));
     // settings navigation
     $navigationSettingsId = $this->setNavigation(null, 'Settings');
     $navigationModulesId = $this->setNavigation($navigationSettingsId, 'Modules');
     $this->setNavigation($navigationModulesId, 'Blog', 'blog/settings');
     // add extra's
     $blogId = $this->insertExtra('Blog', ModuleExtraType::block(), 'Blog', null, null, 'N', 1000);
     $this->insertExtra('Blog', ModuleExtraType::widget(), 'RecentComments', 'RecentComments', null, 'N', 1001);
     $this->insertExtra('Blog', ModuleExtraType::widget(), 'Categories', 'Categories', null, 'N', 1002);
     $this->insertExtra('Blog', ModuleExtraType::widget(), 'Archive', 'Archive', null, 'N', 1003);
     $this->insertExtra('Blog', ModuleExtraType::widget(), 'RecentArticlesFull', 'RecentArticlesFull', null, 'N', 1004);
     $this->insertExtra('Blog', ModuleExtraType::widget(), 'RecentArticlesList', 'RecentArticlesList', null, 'N', 1005);
     // get search extra id
     $searchId = (int) $this->getDB()->getVar('SELECT id FROM modules_extras
          WHERE module = ? AND type = ? AND action = ?', array('Search', ModuleExtraType::WIDGET, 'Form'));
     // loop languages
     foreach ($this->getLanguages() as $language) {
         // fetch current categoryId
         $this->defaultCategoryId = $this->getCategory($language);
         // no category exists
         if ($this->defaultCategoryId == 0) {
             // add category
             $this->defaultCategoryId = $this->addCategory($language, 'Default', 'default');
         }
         // RSS settings
         $this->setSetting('Blog', 'rss_meta_' . $language, true);
         $this->setSetting('Blog', 'rss_title_' . $language, 'RSS');
         $this->setSetting('Blog', 'rss_description_' . $language, '');
         // check if a page for blog already exists in this language
         if (!(bool) $this->getDB()->getVar('SELECT 1
              FROM pages AS p
              INNER JOIN pages_blocks AS b ON b.revision_id = p.revision_id
              WHERE b.extra_id = ? AND p.language = ?
              LIMIT 1', array($blogId, $language))) {
             $this->insertPage(array('title' => 'Blog', 'language' => $language), null, array('extra_id' => $blogId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
         }
         if ($this->installExample()) {
             $this->installExampleData($language);
         }
     }
 }
Esempio n. 9
0
 /**
  * Install the module.
  */
 public function install()
 {
     // load install.sql
     $this->importSQL(__DIR__ . '/Data/install.sql');
     // add 'profiles' as a module
     $this->addModule('Profiles');
     // import locale
     $this->importLocale(__DIR__ . '/Data/locale.xml');
     // general settings
     $this->setSetting('Profiles', 'allow_gravatar', true);
     $this->setSetting('Profiles', 'overwrite_profile_notification_email', false);
     $this->setSetting('Profiles', 'profile_notification_email', null);
     $this->setSetting('Profiles', 'send_mail_for_new_profile_to_admin', false);
     $this->setSetting('Profiles', 'send_mail_for_new_profile_to_profile', false);
     // add folders
     $filesystem = new Filesystem();
     $filesystem->mkdir(PATH_WWW . '/src/Frontend/Files/Profiles/avatars/source/');
     $filesystem->mkdir(PATH_WWW . '/src/Frontend/Files/Profiles/avatars/240x240/');
     $filesystem->mkdir(PATH_WWW . '/src/Frontend/Files/Profiles/avatars/64x64/');
     $filesystem->mkdir(PATH_WWW . '/src/Frontend/Files/Profiles/avatars/32x32/');
     // module rights
     $this->setModuleRights(1, 'Profiles');
     // action rights
     $this->setActionRights(1, 'Profiles', 'Add');
     $this->setActionRights(1, 'Profiles', 'AddGroup');
     $this->setActionRights(1, 'Profiles', 'AddProfileGroup');
     $this->setActionRights(1, 'Profiles', 'Block');
     $this->setActionRights(1, 'Profiles', 'DeleteGroup');
     $this->setActionRights(1, 'Profiles', 'DeleteProfileGroup');
     $this->setActionRights(1, 'Profiles', 'Delete');
     $this->setActionRights(1, 'Profiles', 'EditGroup');
     $this->setActionRights(1, 'Profiles', 'EditProfileGroup');
     $this->setActionRights(1, 'Profiles', 'Edit');
     $this->setActionRights(1, 'Profiles', 'ExportTemplate');
     $this->setActionRights(1, 'Profiles', 'Groups');
     $this->setActionRights(1, 'Profiles', 'Import');
     $this->setActionRights(1, 'Profiles', 'Index');
     $this->setActionRights(1, 'Profiles', 'MassAction');
     // set navigation
     $navigationModulesId = $this->setNavigation(null, 'Modules');
     $navigationProfilesId = $this->setNavigation($navigationModulesId, 'Profiles');
     $this->setNavigation($navigationProfilesId, 'Overview', 'profiles/index', array('profiles/add', 'profiles/edit', 'profiles/add_profile_group', 'profiles/edit_profile_group', 'profiles/import'));
     $this->setNavigation($navigationProfilesId, 'Groups', 'profiles/groups', array('profiles/add_group', 'profiles/edit_group'));
     // settings navigation
     $navigationSettingsId = $this->setNavigation(null, 'Settings');
     $navigationModulesId = $this->setNavigation($navigationSettingsId, 'Modules');
     $this->setNavigation($navigationModulesId, 'Profiles', 'profiles/settings');
     // add extra
     $activateId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Activate', 'Activate', null, 'N', 5000);
     $forgotPasswordId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ForgotPassword', 'ForgotPassword', null, 'N', 5001);
     $indexId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Dashboard', null, null, 'N', 5002);
     $loginId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Login', 'Login', null, 'N', 5003);
     $logoutId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Logout', 'Logout', null, 'N', 5004);
     $changeEmailId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ChangeEmail', 'ChangeEmail', null, 'N', 5005);
     $changePasswordId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ChangePassword', 'ChangePassword', null, 'N', 5006);
     $settingsId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Settings', 'Settings', null, 'N', 5007);
     $registerId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Register', 'Register', null, 'N', 5008);
     $resetPasswordId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ResetPassword', 'ResetPassword', null, 'N', 5008);
     $resendActivationId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ResendActivation', 'ResendActivation', null, 'N', 5009);
     $this->insertExtra('Profiles', ModuleExtraType::widget(), 'LoginBox', 'LoginBox', null, 'N', 5010);
     $this->insertExtra('Profiles', ModuleExtraType::widget(), 'LoginLink', 'LoginLink', null, 'N', 5011);
     $this->insertExtra('Profiles', ModuleExtraType::widget(), 'SecurePage', 'SecurePage', null, 'N', 5012);
     // get search widget id
     $searchId = (int) $this->getDB()->getVar('SELECT id FROM modules_extras WHERE module = ? AND action = ?', array('search', 'form'));
     $originalLocale = Language::getInterfaceLanguage();
     // loop languages
     foreach ($this->getLanguages() as $language) {
         // only add pages if profiles isn't linked anywhere
         // @todo refactor me, syntax sucks atm
         if (!(bool) $this->getDB()->getVar('SELECT 1
              FROM pages AS p
              INNER JOIN pages_blocks AS b ON b.revision_id = p.revision_id
              INNER JOIN modules_extras AS e ON e.id = b.extra_id
              WHERE e.module = ? AND p.language = ?
              LIMIT 1', array('Profiles', $language))) {
             // We must define the locale we want to insert the page into
             Language::setLocale($language);
             // activate page
             $this->insertPage(array('title' => ucfirst(Language::lbl('Activate')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $activateId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // forgot password page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ForgotPassword')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $forgotPasswordId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // reset password page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ResetPassword')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $resetPasswordId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // resend activation email page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ResendActivation')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $resendActivationId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // login page
             $this->insertPage(array('title' => ucfirst(Language::lbl('Login')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $loginId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // register page
             $this->insertPage(array('title' => ucfirst(Language::lbl('Register')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $registerId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // logout page
             $this->insertPage(array('title' => ucfirst(Language::lbl('Logout')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $logoutId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // index page
             $indexPageId = $this->insertPage(array('title' => ucfirst(Language::lbl('Profile')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $indexId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // settings page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ProfileSettings')), 'parent_id' => $indexPageId, 'language' => $language), null, array('extra_id' => $settingsId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // change email page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ChangeEmail')), 'parent_id' => $indexPageId, 'language' => $language), null, array('extra_id' => $changeEmailId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // change password page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ChangePassword')), 'parent_id' => $indexPageId, 'language' => $language), null, array('extra_id' => $changePasswordId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
         }
     }
     // restore the original locale
     if (!empty($originalLocale)) {
         Language::setLocale($originalLocale);
     }
 }
Esempio n. 10
0
 /**
  * Insert an item
  *
  * @param array $item The data of the record to insert.
  *
  * @return int
  */
 public static function insert($item)
 {
     $db = BackendModel::getContainer()->get('database');
     // insert extra
     $item['extra_id'] = BackendModel::insertExtra(ModuleExtraType::widget(), 'Location');
     // insert new location
     $item['created_on'] = $item['edited_on'] = BackendModel::getUTCDate();
     $item['id'] = $db->insert('location', $item);
     // update extra (item id is now known)
     BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => \SpoonFilter::ucfirst(BL::lbl('Location', 'Core')) . ': ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('Edit') . '&id=' . $item['id']));
     return $item['id'];
 }
 /**
  * @return int
  */
 private function getNewExtraId()
 {
     return Model::insertExtra(ModuleExtraType::widget(), 'ContentBlocks', 'Detail');
 }
Esempio n. 12
0
 /**
  * Install the module
  */
 public function install()
 {
     // load install.sql
     $this->importSQL(__DIR__ . '/Data/install.sql');
     // add as a module
     $this->addModule('FormBuilder');
     // import locale
     $this->importLocale(__DIR__ . '/Data/locale.xml');
     // module rights
     $this->setModuleRights(1, 'FormBuilder');
     // action rights
     $this->setActionRights(1, 'FormBuilder', 'Add');
     $this->setActionRights(1, 'FormBuilder', 'Edit');
     $this->setActionRights(1, 'FormBuilder', 'Delete');
     $this->setActionRights(1, 'FormBuilder', 'Index');
     $this->setActionRights(1, 'FormBuilder', 'Data');
     $this->setActionRights(1, 'FormBuilder', 'DataDetails');
     $this->setActionRights(1, 'FormBuilder', 'MassDataAction');
     $this->setActionRights(1, 'FormBuilder', 'GetField');
     $this->setActionRights(1, 'FormBuilder', 'DeleteField');
     $this->setActionRights(1, 'FormBuilder', 'SaveField');
     $this->setActionRights(1, 'FormBuilder', 'Sequence');
     $this->setActionRights(1, 'FormBuilder', 'ExportData');
     // set navigation
     $navigationModulesId = $this->setNavigation(null, 'Modules');
     $this->setNavigation($navigationModulesId, 'FormBuilder', 'form_builder/index', array('form_builder/add', 'form_builder/edit', 'form_builder/data', 'form_builder/data_details'));
     // get search extra id
     $searchId = (int) $this->getDB()->getVar('SELECT id
          FROM modules_extras
          WHERE module = ? AND type = ? AND action = ?', array('search', ModuleExtraType::WIDGET, 'form'));
     // loop languages
     foreach ($this->getLanguages() as $language) {
         // create form
         $form = array();
         $form['language'] = $language;
         $form['user_id'] = $this->getDefaultUserID();
         $form['name'] = \SpoonFilter::ucfirst($this->getLocale('Contact', 'Core', $language, 'lbl', 'Frontend'));
         $form['method'] = 'database_email';
         $form['email'] = serialize(array($this->getVariable('email')));
         $form['success_message'] = $this->getLocale('ContactMessageSent', 'Core', $language, 'msg', 'Frontend');
         $form['identifier'] = 'contact-' . $language;
         $form['created_on'] = gmdate('Y-m-d H:i:s');
         $form['edited_on'] = gmdate('Y-m-d H:i:s');
         $formId = $this->getDB()->insert('forms', $form);
         // create submit button
         $field['form_id'] = $formId;
         $field['type'] = 'submit';
         $field['settings'] = serialize(array('values' => \SpoonFilter::ucfirst($this->getLocale('Send', 'Core', $language, 'lbl', 'Frontend'))));
         $this->getDB()->insert('forms_fields', $field);
         // create name field
         $field['form_id'] = $formId;
         $field['type'] = 'textbox';
         $field['settings'] = serialize(array('label' => \SpoonFilter::ucfirst($this->getLocale('Name', 'Core', $language, 'lbl', 'Frontend'))));
         $nameId = $this->getDB()->insert('forms_fields', $field);
         // name validation
         $validate['field_id'] = $nameId;
         $validate['type'] = 'required';
         $validate['error_message'] = $this->getLocale('NameIsRequired', 'Core', $language, 'err', 'Frontend');
         $this->getDB()->insert('forms_fields_validation', $validate);
         // create email field
         $field['form_id'] = $formId;
         $field['type'] = 'textbox';
         $field['settings'] = serialize(array('label' => \SpoonFilter::ucfirst($this->getLocale('Email', 'Core', $language, 'lbl', 'Frontend'))));
         $emailId = $this->getDB()->insert('forms_fields', $field);
         // email validation
         $validate['field_id'] = $emailId;
         $validate['type'] = 'email';
         $validate['error_message'] = $this->getLocale('EmailIsInvalid', 'Core', $language, 'err', 'Frontend');
         $this->getDB()->insert('forms_fields_validation', $validate);
         // create message field
         $field['form_id'] = $formId;
         $field['type'] = 'textarea';
         $field['settings'] = serialize(array('label' => \SpoonFilter::ucfirst($this->getLocale('Message', 'Core', $language, 'lbl', 'Frontend'))));
         $messageId = $this->getDB()->insert('forms_fields', $field);
         // name validation
         $validate['field_id'] = $messageId;
         $validate['type'] = 'required';
         $validate['error_message'] = $this->getLocale('MessageIsRequired', 'Core', $language, 'err', 'Frontend');
         $this->getDB()->insert('forms_fields_validation', $validate);
         // insert extra
         $extraId = $this->insertExtra('FormBuilder', ModuleExtraType::widget(), 'FormBuilder', 'Form', serialize(array('language' => $form['language'], 'extra_label' => $form['name'], 'id' => $formId)), 'N', '400' . $formId);
         // insert contact page
         $this->insertPage(array('title' => \SpoonFilter::ucfirst($this->getLocale('Contact', 'Core', $language, 'lbl', 'Frontend')), 'parent_id' => 1, 'language' => $language), null, array('html' => PATH_WWW . '/src/Backend/Modules/Pages/Installer/Data/' . $language . '/contact.txt'), array('extra_id' => $extraId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
     }
 }
Esempio n. 13
0
 /**
  * Install the module
  */
 public function install()
 {
     $this->importSQL(__DIR__ . '/Data/install.sql');
     $this->addModule('Faq');
     $this->importLocale(__DIR__ . '/Data/locale.xml');
     $this->makeSearchable('Faq');
     $this->setModuleRights(1, 'Faq');
     $this->setActionRights(1, 'Faq', 'Index');
     $this->setActionRights(1, 'Faq', 'Add');
     $this->setActionRights(1, 'Faq', 'Edit');
     $this->setActionRights(1, 'Faq', 'Delete');
     $this->setActionRights(1, 'Faq', 'Sequence');
     $this->setActionRights(1, 'Faq', 'Categories');
     $this->setActionRights(1, 'Faq', 'AddCategory');
     $this->setActionRights(1, 'Faq', 'EditCategory');
     $this->setActionRights(1, 'Faq', 'DeleteCategory');
     $this->setActionRights(1, 'Faq', 'SequenceQuestions');
     $this->setActionRights(1, 'Faq', 'DeleteFeedback');
     $this->setActionRights(1, 'Faq', 'Settings');
     $faqId = $this->insertExtra('Faq', ModuleExtraType::block(), 'Faq');
     // Register widgets
     // Category faq widgets will be added on the fly
     $this->insertExtra('Faq', ModuleExtraType::widget(), 'MostReadQuestions', 'MostReadQuestions');
     $this->insertExtra('Faq', ModuleExtraType::widget(), 'AskOwnQuestion', 'AskOwnQuestion');
     $this->insertExtra('Faq', ModuleExtraType::widget(), 'Categories', 'Categories');
     $this->setSetting('Faq', 'overview_num_items_per_category', 0);
     $this->setSetting('Faq', 'most_read_num_items', 0);
     $this->setSetting('Faq', 'related_num_items', 0);
     $this->setSetting('Faq', 'spamfilter', false);
     $this->setSetting('Faq', 'allow_feedback', false);
     $this->setSetting('Faq', 'allow_own_question', false);
     $this->setSetting('Faq', 'allow_multiple_categories', true);
     $this->setSetting('Faq', 'send_email_on_new_feedback', false);
     foreach ($this->getLanguages() as $language) {
         $this->defaultCategoryId = $this->getCategory($language);
         // no category exists
         if ($this->defaultCategoryId == 0) {
             $this->defaultCategoryId = $this->addCategory($language, 'Default', 'default');
         }
         // check if a page for the faq already exists in this language
         $faqPageExists = (bool) $this->getDB()->getVar('SELECT 1
              FROM pages AS p
              INNER JOIN pages_blocks AS b ON b.revision_id = p.revision_id
              WHERE b.extra_id = ? AND p.language = ?
              LIMIT 1', array($faqId, $language));
         if (!$faqPageExists) {
             // insert page
             $this->insertPage(array('title' => 'FAQ', 'language' => $language), null, array('extra_id' => $faqId));
         }
     }
     $this->insertWidget();
     // set navigation
     $navigationModulesId = $this->setNavigation(null, 'Modules');
     $navigationFaqId = $this->setNavigation($navigationModulesId, 'Faq');
     $this->setNavigation($navigationFaqId, 'Questions', 'faq/index', array('faq/add', 'faq/edit'));
     $this->setNavigation($navigationFaqId, 'Categories', 'faq/categories', array('faq/add_category', 'faq/edit_category'));
     $navigationSettingsId = $this->setNavigation(null, 'Settings');
     $navigationModulesId = $this->setNavigation($navigationSettingsId, 'Modules');
     $this->setNavigation($navigationModulesId, 'Faq', 'faq/settings');
 }
Esempio n. 14
0
 /**
  * Insert a category in the database
  *
  * @param array $item
  * @param array $meta The metadata for the category to insert.
  *
  * @return int
  */
 public static function insertCategory(array $item, $meta = null)
 {
     $db = BackendModel::get('database');
     // insert the meta if possible
     if ($meta !== null) {
         $item['meta_id'] = $db->insert('meta', $meta);
     }
     // insert extra
     $item['extra_id'] = BackendModel::insertExtra(ModuleExtraType::widget(), 'Faq', 'CategoryList');
     $item['id'] = $db->insert('faq_categories', $item);
     // update extra (item id is now known)
     BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => \SpoonFilter::ucfirst(BL::lbl('Category', 'Faq')) . ': ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('EditCategory', 'Faq', $item['language']) . '&id=' . $item['id']));
     return $item['id'];
 }