public function createExtensions() { $Extension = new Extension(); $this->AdminUsers = $Extension->create(array('name' => 'Admin::Users', 'is_core' => true, 'is_enabled' => true)); $this->AdminPermissions = $Extension->create(array('name' => 'Admin::Permissions', 'is_core' => true, 'is_enabled' => true)); $this->AdminRoles = $Extension->create(array('name' => 'Admin::Roles', 'is_core' => true, 'is_enabled' => true)); $this->AdminDashboard = $Extension->create(array('name' => 'Admin::Dashboard', 'is_core' => true, 'is_enabled' => true)); $this->AdminMenuTabs = $Extension->create(array('name' => 'Admin Menu Tabs', 'is_core' => true, 'is_enabled' => true)); }
/** * @param array|string $synonyms * @param Extension $extension */ public function addExtension($synonyms, Extension $extension) { if (!is_array($synonyms)) { $synonyms = array($synonyms); } foreach ($synonyms as $synonym) { $extension->init($this); $this->extensions[$synonym] = $extension; } }
public function __construct() { parent::__construct(); $this->errors = new MessageStack(); $this->fields = array(); $this->editing = $this->failed = false; $this->datasource = $this->handle = $this->status = $this->type = NULL; $this->types = array(); foreach (new ExtensionIterator(ExtensionIterator::FLAG_TYPE, array('Data Source')) as $extension) { $path = Extension::getPathFromClass(get_class($extension)); $handle = Extension::getHandleFromPath($path); if (Extension::status($handle) != Extension::STATUS_ENABLED) { continue; } if (!method_exists($extension, 'getDataSourceTypes')) { continue; } foreach ($extension->getDataSourceTypes() as $type) { $this->types[$type->class] = $type; } } if (empty($this->types)) { $this->alerts()->append(__('There are no Data Source types currently available. You will not be able to create or edit Data Sources.'), AlertStack::ERROR); } }
public function transferFromDOM($node) { parent::transferFromDOM($node); $this->_rootNamespace = null; $this->_rootNamespaceURI = $node->namespaceURI; $this->_rootElement = $node->localName; }
static function add_to_class($class, $extensionClass, $args = null) { if(method_exists($class, 'extraDBFields')) { $extraStaticsMethod = 'extraDBFields'; } else { $extraStaticsMethod = 'extraStatics'; } $statics = singleton($extensionClass)->$extraStaticsMethod($class, $extensionClass); if ($statics) { Deprecation::notice('3.1.0', "$extraStaticsMethod deprecated. Just define statics on your extension, or use add_to_class"); // TODO: This currently makes extraStatics the MOST IMPORTANT config layer, not the least foreach (self::$extendable_statics as $key => $merge) { if (isset($statics[$key])) { if (!$merge) Config::inst()->remove($class, $key); Config::inst()->update($class, $key, $statics[$key]); } } // TODO - remove this DataObject::$cache_has_own_table[$class] = null; DataObject::$cache_has_own_table_field[$class] = null; } parent::add_to_class($class, $extensionClass, $args); }
public function uninstall() { if (parent::uninstall() == true) { Symphony::Database()->query("DROP TABLE `tbl_fields_selectbox_link`"); return true; } return false; }
function setOwner(Object $owner, $ownerBaseClass = null) { if (!$owner instanceof DataObject) { user_error(sprintf("DataObjectDecorator->setOwner(): Trying to decorate an object of class '%s' with '%s', \n\t\t\t\tonly Dataobject subclasses are supported.", get_class($owner), $this->class), E_USER_ERROR); return false; } parent::setOwner($owner, $ownerBaseClass); }
public function __construct() { parent::__construct(); // Validate request passes XSRF checks if extension is enabled. $status = Symphony::ExtensionManager()->fetchStatus(array("handle" => "xsrf_protection")); if (in_array(EXTENSION_ENABLED, $status) || in_array(EXTENSION_REQUIRES_UPDATE, $status)) { XSRF::validateRequest(); } }
public function addMiddlewareByClass($middlewareClass, $middlewareFile) { $this->extension->loadMiddleware($middlewareFile); /** * @var $middleware \MABI\Middleware */ $middleware = new $middlewareClass(); $this->addMiddleware($middleware); }
/** * Re-reads config and refreshes cache. * * @return Yaml * @throws Exception\LoaderException */ protected function refreshCache() { $ext = new Extension(); $ext->load(); try { $yaml = Yaml::load(self::YAML_FILE); } catch (\Exception $e) { throw new Exception\LoaderException(sprintf('Could not load config. %s', $e->getMessage())); } $refSet = new \ReflectionMethod($yaml, 'set'); $refSet->setAccessible(true); $before = clone $yaml; foreach ($ext as $key => $obj) { if (property_exists($obj, 'default') && (!$yaml->defined($key) || $yaml($key) === null)) { //Set defaults only in the case it is provided in the Extension. //Set defaults only if they are not overriden in config and not null. $refSet->invoke($yaml, $key, $obj->default); } //Checks if at least one from all parents is not required. $token = $key; while (strpos($token, '.')) { $token = preg_replace('/\\.[^\\.]+$/', '', $token); //Parent bag is not required if (!$ext->defined($token)) { //And it is not defined in config if (!$before->defined($token)) { continue 2; } else { //check presence of nodes if it is defined in config break; } } } if (!$yaml->defined($key)) { //If, after all, value has not been defined in the Extension, it is considered as user error. throw new Exception\LoaderException(sprintf('Parameter "%s" must be defined in the config', $key)); } } unset($before); //serialize yaml file_put_contents(self::YAML_CACHE_FILE, serialize($yaml)); @chmod(self::YAML_CACHE_FILE, 0666); return $yaml; }
public static function add() { parent::add(); self::$facebook_app_id = Installer::getComposerEvent()->getIO()->ask(":: enter your facebook app id: ", "[app_id]"); self::$facebook_api_secret = Installer::getComposerEvent()->getIO()->ask(":: enter your facebook app secret: ", "[app_secret]"); File::replaceContent(Installer::getRootDirConfig() . self::getConfigfile(), "[app_id]", self::getFacebookAppId()); File::replaceContent(Installer::getRootDirConfig() . self::getConfigfile(), "[api_secret]", self::getFacebookApiSecret()); File::addContent(Installer::getRootDirTheme() . "Includes/Footer.ss", "<% include FacebookLoginLink %>", "SilverStripe</a></small>"); Installer::getComposerEvent()->getIO()->write(":: added facebookconnect extension"); }
/** * Given a DOMNode representing an attribute, tries to map the data into * instance members. If no mapping is defined, the name and value are * stored in an array. * * @param DOMNode $attribute The DOMNode attribute needed to be handled */ protected function takeAttributeFromDOM($attribute) { switch ($attribute->localName) { case 'value': $this->_value = $attribute->nodeValue; break; default: parent::takeAttributeFromDOM($attribute); } }
public static function get_status($extension_id, $project_id) { if (is_numeric($extension_id) and is_numeric($project_id)) { $run_array = ProjectHasExtensionRun_Access::list_runs_by_extension_id_and_project_id($extension_id, $project_id); if (is_array($run_array) and count($run_array) >= 1) { $extension = new Extension($extension_id); $return = 1; foreach ($run_array as $key => $value) { $status = $extension->get_run_status($value); if ($status == 0 or $status == -1) { $return = 0; } } return $return; } else { return -1; } } else { return -1; } }
public function __construct() { parent::__construct(); Requirements::block("photogallery/shadowbox/shadowbox.css"); Requirements::block("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"); Requirements::block("photogallery/shadowbox/shadowbox.js"); Requirements::block("photogallery/js/shadowbox_init.js"); Requirements::CSS("silverstripe-video-embed/assests/javascript/shadowbox/shadowbox.css"); Requirements::javascript("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"); Requirements::javascript("silverstripe-video-embed/assests/javascript/shadowbox/shadowbox.js"); Requirements::javascriptTemplate('silverstripe-video-embed/assests/javascript/shadowbox_init.js', array()); }
/** * @param string $alias * @throws BaseExtensionClassNotFoundException * @throws BaseExtensionFileNotFoundException */ public static function io_handler($alias) { if ($_GET['extension']) { $extension = new Extension($_GET['extension']); $main_file = constant("EXTENSION_DIR") . "/" . $extension->get_folder() . "/" . $extension->get_main_file(); $main_class = $extension->get_class(); if (file_exists($main_file)) { require_once $main_file; if (class_exists($main_class)) { $main_class::main(); } else { throw new BaseExtensionClassNotFoundException(); } } else { throw new BaseExtensionFileNotFoundException(); } } else { require_once "io/extension.io.php"; ExtensionIO::home(); } }
public function generate($ext, $upool) { // Creation by daemon // Generate content $ext_obj = Extension::get($ext); if ($ext_obj == null) { $this->tournament->say("Extension {$ext} not found in booster generation"); return false; } $this->fullcontent = $ext_obj->booster($upool); $this->summarize(); $this->insert(); }
public function appendTo(SymphonyDOMElement $wrapper) { $this->layout->setAttribute('class', $this->class); ### # Delegate: LayoutPreGenerate # Description: Allows developers to access the layout content # before it is appended to the page. Extension::notify('LayoutPreGenerate', '/administration/', $this->layout); if ($wrapper->tagName == 'form') { $this->layout->setAttribute('id', 'layout'); } $wrapper->appendChild($this->layout); }
/** * */ public function __construct() { parent::__construct(); $appId = Config::inst()->get('FacebookControllerExtension', 'app_id'); $secret = Config::inst()->get('FacebookControllerExtension', 'api_secret'); if (!$appId || !$secret) { return null; } FacebookSession::setDefaultApplication($appId, $secret); if (session_status() !== PHP_SESSION_ACTIVE) { Session::start(); } }
public function uninstall() { if (parent::uninstall() == true) { try { Symphony::Database()->query("DROP TABLE `tbl_fields_metakeys`"); return true; } catch (Exception $ex) { $extension = $this->about(); Administration::instance()->Page->pageAlert(__('An error occurred while uninstalling %s. %s', array($extension['name'], $ex->getMessage())), Alert::ERROR); return false; } } return false; }
protected function takeChildFromDOM($child) { $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; switch ($absoluteNodeName) { case $this->lookupNamespace('app') . ':' . 'draft': $draft = new Draft(); $draft->transferFromDOM($child); $this->_draft = $draft; break; default: parent::takeChildFromDOM($child); break; } }
/** * @see http://symphony-cms.com/learn/api/2.2/toolkit/extension/#__construct */ public function __construct(array $args) { parent::__construct($args); // Include Stage if (!class_exists('Stage')) { try { if ((include_once EXTENSIONS . '/datetime/lib/stage/class.stage.php') === FALSE) { throw new Exception(); } } catch (Exception $e) { throw new SymphonyErrorPage(__('Please make sure that the Stage submodule is initialised and available at %s.', array('<code>' . EXTENSIONS . '/datetime/lib/stage/</code>')) . '<br/><br/>' . __('It\'s available at %s.', array('<a href="https://github.com/nilshoerrmann/stage">github.com/nilshoerrmann/stage</a>')), __('Stage not found')); } } }
public function testSetsGetsProperties() { $instance = new Extension(static::$name, static::$file, static::$type, static::$client, static::$group); self::assertEquals('plg_system_test', $instance->getName()); self::assertEquals('some_file.zip', $instance->getFile()->getName()); self::assertEquals('plugin', $instance->getType()); self::assertEquals(null, $instance->getClient()); self::assertEquals('system', $instance->getGroup()); }
/** * @see http://symphony-cms.com/learn/api/2.3/toolkit/extension/#__construct */ public function __construct(array $args) { parent::__construct($args); // Prepare cache if (file_exists(CACHE . '/subsectionmanager-storage')) { // If Data Source files have not changed, get cache if (filemtime(DATASOURCES) < filemtime(CACHE . '/subsectionmanager-storage')) { $cache = unserialize(file_get_contents(CACHE . '/subsectionmanager-storage')); } // Check store cache if (!empty($cache)) { self::$storage['fields'] = $cache['fields']; self::$updateCache = false; } } }
protected function takeAttributeFromDOM($attribute) { switch ($attribute->localName) { case 'term': $this->_term = $attribute->nodeValue; break; case 'scheme': $this->_scheme = $attribute->nodeValue; break; case 'label': $this->_label = $attribute->nodeValue; break; default: parent::takeAttributeFromDOM($attribute); } }
public function init() { parent::init(); if ($message = Session::get('Status')) { $this->owner->StatusMessage = DBField::create_field('HTMLText', $message['message']); $this->owner->StatusType = isset($message['type']) ? $message['type'] : 'success'; Session::clear('Status'); } else { $messages = Session::get_all(); if ($messages && isset($messages['FormInfo'])) { foreach ($messages['FormInfo'] as $name => $message) { if (isset($message['formError'])) { $this->owner->StatusMessage = DBField::create_field('HTMLText', $message['formError']['message']); $this->owner->StatusType = isset($message['formError']['type']) ? $message['formError']['type'] : 'success'; } } Session::clear('FormInfo'); } } if ($this->owner->StatusMessage) { $this->owner->StatusMessage = html_entity_decode($this->owner->StatusMessage); } }
/** * Register component */ public function register($base_path) { if (!file_exists($base_path) && !is_dir($base_path)) { throw new ExtensionException(sprintf('path %s not exists', $base_path)); } if (!isset($this->base_path)) { $this->base_path = $base_path; } $this->component = basename($base_path); $this->component_name = $this->component; $this->registerLanguage(); $this->registerFiles(['model', 'view', 'controller', 'table'], $base_path); $this->registerRoutes(); $this->includeInitialize(); if ($this->base_path == $base_path) { $pluginArchitecture = Extension::get('plugin'); $pluginArchitecture->register($this->base_path); } $hmvc_base_path = $base_path . DIRECTORY_SEPARATOR . 'components'; if (file_exists($hmvc_base_path) && is_dir($hmvc_base_path)) { $this->register($hmvc_base_path); } }
/** * Constructor * * Reads project's and default .ini file, sets project handler's * and initializes paths. * @param location config file */ public function __construct() { parent::__construct(); $this->configFile = strtolower(__CLASS__ . ".ini"); $this->template = array(); $this->templateFile = "intrusion.tpl"; $this->basePath = realpath(dirname(__FILE__) . "/../") . "/"; $this->intrusionUpdated = false; $this->pagesize = 20; $this->log = Logger::getInstance(); $this->sqlParser->setSelect('select'); $this->sqlParser->setTable('intrusion', 'a'); $this->sqlParser->addField(new SqlField('a', 'intr_ip', 'ip', 'Ip address', SqlParser::getTypeSelect() | SqlParser::getTypeModify() | SqlParser::PKEY, SqlField::TYPE_STRING, true)); $this->sqlParser->addField(new SqlField('a', 'intr_permanent', 'permanent', 'Permanent', SqlParser::getTypeSelect() | SqlParser::getTypeModify(), SqlField::TYPE_BOOLEAN)); $this->sqlParser->addField(new SqlField('a', 'intr_count', 'count', 'Intrusion attempts', SqlParser::getTypeSelect() | SqlParser::getTypeModify(), SqlField::TYPE_INTEGER, true)); $this->sqlParser->addField(new SqlField('a', 'intr_create', 'createdate', 'Created', SqlParser::getTypeSelect() | SqlParser::MOD_INSERT, SqlField::TYPE_DATE, true)); $this->sqlParser->addField(new SqlField('a', 'intr_ts', 'ts', 'Modified', SqlParser::getTypeSelect(), SqlField::TYPE_DATE)); //add new view types $view = ViewManager::getInstance(); $view->insert(self::VIEW_OVERVIEW, 'Overview'); $view->insert(self::VIEW_NEW, 'New'); $view->insert(self::VIEW_EDIT, 'Edit'); $view->insert(self::VIEW_DELETE, 'Delete'); }
public function __construct() { parent::__construct(); $this->team_repository = new SapphireTeamRepository(); }
Extension::enabling(function (Extension $extension) { // Before an extension is enabled }); Extension::enabled(function (Extension $extension) { // After an extension is enabled }); Extension::disabling(function (Extension $extension) { // Before an extension is disabled }); Extension::disabled(function (Extension $extension) { // After an extension is disabled }); Extension::upgrading(function (Extension $extension) { // Before an extension is upgraded }); Extension::upgraded(function (Extension $extension) { // After an extension is upgraded }); /* |-------------------------------------------------------------------------- | Miscellaneous Hooks |-------------------------------------------------------------------------- | | Hooks for all other parts of Platform. | */ if (class_exists('Page')) { Page::rendering(function (Page $page) { // Page is rendering, return an array of additional data }); }
public function __construct() { parent::__construct(); }