Esempio n. 1
0
 public function actionGet()
 {
     if (isset($_GET['id'])) {
         $id = $_GET['id'];
         $resource = ResourceManager::manager()->getResourceById($this->resourceType, $id);
         if ($resource) {
             $this->responseBuilder->addResource($resource);
         } else {
             $this->responseBuilder->makeResponseError(2, "Could not find resource with id=" . $id);
         }
     } else {
         $from = $_GET['from'];
         $count = $_GET['count'];
         if (!isset($from)) {
             $from = ResourceController::DEFAULT_FROM;
         }
         if (!isset($count)) {
             $count = ResourceController::DEFAULT_COUNT;
         }
         if ($count < 0) {
             $this->responseBuilder->makeResponseError(1, "Count value must be more than 0");
         }
         if ($from < 0) {
             $this->responseBuilder->makeResponseError(1, "From value must be more than 0");
         }
         $resources = ResourceManager::manager()->getResources($this->resourceType, $from, $count);
         if (count($resource) > 0) {
             foreach ($resources as $oneResource) {
                 $this->responseBuilder->addResource($oneResource);
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function offsetGet($offset)
 {
     try {
         return $this->resources->getRequest($offset);
     } catch (\InvalidArgumentException $e) {
     }
     try {
         return $this->resources->getUrl($offset);
     } catch (\InvalidArgumentException $e) {
     }
     try {
         return $this->resources->getPath($offset);
     } catch (\InvalidArgumentException $e) {
     }
     return null;
 }
Esempio n. 3
0
 /**
  * getInstance
  * Singleton method to return static instance of ResourceManager
  * @return The static singleton ResourceManager instance
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new ResourceManager();
     }
     // if
     return self::$instance;
 }
Esempio n. 4
0
 /**
  * get the xml content of  the resource
  * @return the resource xml content
  */
 public function actionGetResourceXml()
 {
     $id = intval($_GET['id']);
     $data = ResourceManager::findById($id);
     if ($data) {
         header('Content-Type: text/xml');
         echo $data->uploaded_xml;
     } else {
         echo '未找到ID为$id的资源';
     }
 }
Esempio n. 5
0
 /**
  * setupResourceManagement
  * This function initialize the ResourceManager and calls the setup method
  * on the ResourceManager instance.
  *
  */
 function setupResourceManagement($module)
 {
     require_once 'include/resource/ResourceManager.php';
     $resourceManager = ResourceManager::getInstance();
     $resourceManager->setup($module);
 }
 public function __formAction()
 {
     $fields = $_POST['fields'];
     $this->_errors = array();
     $providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::EVENT);
     $providerClass = null;
     if (trim($fields['name']) == '') {
         $this->_errors['name'] = __('This is a required field');
     }
     if (trim($fields['source']) == '') {
         $this->_errors['source'] = __('This is a required field');
     }
     $filters = isset($fields['filters']) ? $fields['filters'] : array();
     // See if a Provided Datasource is saved
     if (!empty($providers)) {
         foreach ($providers as $providerClass => $provider) {
             if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) {
                 call_user_func_array(array($providerClass, 'validate'), array(&$fields, &$this->_errors));
                 break;
             }
             unset($providerClass);
         }
     }
     $classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => ''));
     $rootelement = str_replace('_', '-', $classname);
     $extends = 'SectionEvent';
     // Check to make sure the classname is not empty after handlisation.
     if (empty($classname) && !isset($this->_errors['name'])) {
         $this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($classname));
     }
     $file = EVENTS . '/event.' . $classname . '.php';
     $isDuplicate = false;
     $queueForDeletion = null;
     if ($this->_context[0] == 'new' && is_file($file)) {
         $isDuplicate = true;
     } elseif ($this->_context[0] == 'edit') {
         $existing_handle = $this->_context[1];
         if ($classname != $existing_handle && is_file($file)) {
             $isDuplicate = true;
         } elseif ($classname != $existing_handle) {
             $queueForDeletion = EVENTS . '/event.' . $existing_handle . '.php';
         }
     }
     // Duplicate
     if ($isDuplicate) {
         $this->_errors['name'] = __('An Event with the name %s already exists', array('<code>' . $classname . '</code>'));
     }
     if (empty($this->_errors)) {
         $multiple = in_array('expect-multiple', $filters);
         $elements = null;
         $placeholder = '<!-- GRAB -->';
         $source = $fields['source'];
         $params = array('rootelement' => $rootelement);
         $about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Symphony::Author()->getFullName(), 'author website' => URL, 'author email' => Symphony::Author()->get('email'));
         // If there is a provider, get their template
         if ($providerClass) {
             $eventShell = file_get_contents(call_user_func(array($providerClass, 'getTemplate')));
         } else {
             $eventShell = file_get_contents($this->getTemplate('blueprints.event'));
             $about['trigger condition'] = $rootelement;
         }
         $this->__injectAboutInformation($eventShell, $about);
         // Replace the name
         $eventShell = str_replace('<!-- CLASS NAME -->', $classname, $eventShell);
         // Build the templates
         if ($providerClass) {
             $eventShell = call_user_func(array($providerClass, 'prepare'), $fields, $params, $eventShell);
         } else {
             $this->__injectFilters($eventShell, $filters);
             // Add Documentation
             require_once CONTENT . '/content.ajaxeventdocumentation.php';
             $ajaxEventDoc = new contentAjaxEventDocumentation();
             $documentation = null;
             $doc_parts = array();
             // Add Documentation (Success/Failure)
             $ajaxEventDoc->addEntrySuccessDoc($doc_parts, $rootelement, $fields['source'], $filters);
             $ajaxEventDoc->addEntryFailureDoc($doc_parts, $rootelement, $fields['source'], $filters);
             // Filters
             $ajaxEventDoc->addDefaultFiltersDoc($doc_parts, $rootelement, $fields['source'], $filters);
             // Frontend Markup
             $ajaxEventDoc->addFrontendMarkupDoc($doc_parts, $rootelement, $fields['source'], $filters);
             $ajaxEventDoc->addSendMailFilterDoc($doc_parts, $rootelement, $fields['source'], $filters);
             /**
              * Allows adding documentation for new filters. A reference to the $documentation
              * array is provided, along with selected filters
              * @delegate AppendEventFilterDocumentation
              * @param string $context
              * '/blueprints/events/(edit|new|info)/'
              * @param array $selected
              *  An array of all the selected filters for this Event
              * @param array $documentation
              *  An array of all the documentation XMLElements, passed by reference
              */
             Symphony::ExtensionManager()->notifyMembers('AppendEventFilterDocumentation', '/blueprints/events/' . $rootelement . '/', array('selected' => $filters, 'documentation' => &$doc_parts));
             $documentation = join(PHP_EOL, array_map(create_function('$x', 'return rtrim($x->generate(true, 4));'), $doc_parts));
             $documentation = str_replace('\'', '\\\'', $documentation);
             $eventShell = str_replace('<!-- CLASS EXTENDS -->', $extends, $eventShell);
             $eventShell = str_replace('<!-- DOCUMENTATION -->', General::tabsToSpaces($documentation, 4), $eventShell);
         }
         $eventShell = str_replace('<!-- ROOT ELEMENT -->', $rootelement, $eventShell);
         $eventShell = str_replace('<!-- CLASS NAME -->', $classname, $eventShell);
         $eventShell = str_replace('<!-- SOURCE -->', $source, $eventShell);
         // Remove left over placeholders
         $eventShell = preg_replace(array('/<!--[\\w ]++-->/'), '', $eventShell);
         if ($this->_context[0] == 'new') {
             /**
              * Prior to creating an Event, the file path where it will be written to
              * is provided and well as the contents of that file.
              *
              * @delegate EventsPreCreate
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/events/'
              * @param string $file
              *  The path to the Event file
              * @param string $contents
              *  The contents for this Event as a string passed by reference
              * @param array $filters
              *  An array of the filters attached to this event
              */
             Symphony::ExtensionManager()->notifyMembers('EventPreCreate', '/blueprints/events/', array('file' => $file, 'contents' => &$eventShell, 'filters' => $filters));
         } else {
             /**
              * Prior to editing an Event, the file path where it will be written to
              * is provided and well as the contents of that file.
              *
              * @delegate EventPreEdit
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/events/'
              * @param string $file
              *  The path to the Event file
              * @param string $contents
              *  The contents for this Event as a string passed by reference
              * @param array $filters
              *  An array of the filters attached to this event
              */
             Symphony::ExtensionManager()->notifyMembers('EventPreEdit', '/blueprints/events/', array('file' => $file, 'contents' => &$eventShell, 'filters' => $filters));
         }
         // Write the file
         if (!is_writable(dirname($file)) || !($write = General::writeFile($file, $eventShell, Symphony::Configuration()->get('write_mode', 'file')))) {
             $this->pageAlert(__('Failed to write Event to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/events</code>')), Alert::ERROR);
             // Write successful
         } else {
             if (function_exists('opcache_invalidate')) {
                 opcache_invalidate($file, true);
             }
             // Attach this event to pages
             $connections = $fields['connections'];
             ResourceManager::setPages(RESOURCE_TYPE_EVENT, is_null($existing_handle) ? $classname : $existing_handle, $connections);
             if ($queueForDeletion) {
                 General::deleteFile($queueForDeletion);
                 $pages = PageManager::fetch(false, array('events', 'id'), array("\n                        `events` REGEXP '[[:<:]]" . $existing_handle . "[[:>:]]'\n                    "));
                 if (is_array($pages) && !empty($pages)) {
                     foreach ($pages as $page) {
                         $page['events'] = preg_replace('/\\b' . $existing_handle . '\\b/i', $classname, $page['events']);
                         PageManager::edit($page['id'], $page);
                     }
                 }
             }
             if ($this->_context[0] == 'new') {
                 /**
                  * After creating the Event, the path to the Event file is provided
                  *
                  * @delegate EventPostCreate
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/events/'
                  * @param string $file
                  *  The path to the Event file
                  */
                 Symphony::ExtensionManager()->notifyMembers('EventPostCreate', '/blueprints/events/', array('file' => $file));
             } else {
                 /**
                  * After editing the Event, the path to the Event file is provided
                  *
                  * @delegate EventPostEdit
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/events/'
                  * @param string $file
                  *  The path to the Event file
                  * @param string $previous_file
                  *  The path of the previous Event file in the case where an Event may
                  *  have been renamed. To get the handle from this value, see
                  *  `EventManager::__getHandleFromFilename`
                  */
                 Symphony::ExtensionManager()->notifyMembers('EventPostEdit', '/blueprints/events/', array('file' => $file, 'previous_file' => $queueForDeletion ? $queueForDeletion : null));
             }
             redirect(SYMPHONY_URL . '/blueprints/events/edit/' . $classname . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/');
         }
     }
 }
Esempio n. 7
0
$server->configureWSDL('sugarsoap', $NAMESPACE, $sugar_config['site_url'] . '/soap.php');
//New API is in these files
if (!empty($administrator->settings['portal_on'])) {
    require_once 'soap/SoapPortalUsers.php';
}
require_once 'soap/SoapSugarUsers.php';
//require_once('soap/SoapSugarUsers_version2.php');
require_once 'soap/SoapData.php';
require_once 'soap/SoapDeprecated.php';
/* Begin the HTTP listener service and exit. */
ob_clean();
if (!isset($HTTP_RAW_POST_DATA)) {
    $HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
require_once 'include/resource/ResourceManager.php';
$resourceManager = ResourceManager::getInstance();
$resourceManager->setup('Soap');
$observers = $resourceManager->getObservers();
//Call set_soap_server for SoapResourceObserver instance(s)
foreach ($observers as $observer) {
    if (method_exists($observer, 'set_soap_server')) {
        $observer->set_soap_server($server);
    }
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
global $soap_server_object;
$soap_server_object = $server;
$server->service($HTTP_RAW_POST_DATA);
ob_end_flush();
flush();
sugar_cleanup();
 /**
  * Given a resource type, a handle and an array of pages, this function will
  * ensure that the resource is attached to the given pages. Note that this
  * function will also remove the resource from all pages that are not provided
  * in the `$pages` parameter.
  *
  * @since Symphony 2.4
  * @param integer $type
  *  The resource type, either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DS`
  * @param string $r_handle
  *  The handle of the resource.
  * @param array $pages
  *  An array of Page ID's to attach this resource to.
  * @return boolean
  */
 public static function setPages($type, $r_handle, $pages = array())
 {
     if (!is_array($pages)) {
         $pages = array();
     }
     // Get attached pages
     $attached_pages = ResourceManager::getAttachedPages($type, $r_handle);
     $currently_attached_pages = array();
     foreach ($attached_pages as $page) {
         $currently_attached_pages[] = $page['id'];
     }
     // Attach this datasource to any page that is should be attached to
     $diff_to_attach = array_diff($pages, $currently_attached_pages);
     foreach ($diff_to_attach as $diff_page) {
         ResourceManager::attach($type, $r_handle, $diff_page);
     }
     // Remove this datasource from any page where it once was, but shouldn't be anymore
     $diff_to_detach = array_diff($currently_attached_pages, $pages);
     foreach ($diff_to_detach as $diff_page) {
         ResourceManager::detach($type, $r_handle, $diff_page);
     }
     return true;
 }
 public function __formAction()
 {
     $fields = $_POST['fields'];
     $this->_errors = array();
     $providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::DATASOURCE);
     $providerClass = null;
     if (trim($fields['name']) == '') {
         $this->_errors['name'] = __('This is a required field');
     }
     if ($fields['source'] == 'static_xml') {
         if (trim($fields['static_xml']) == '') {
             $this->_errors['static_xml'] = __('This is a required field');
         } else {
             $xml_errors = null;
             include_once TOOLKIT . '/class.xsltprocess.php';
             General::validateXML($fields['static_xml'], $xml_errors, false, new XsltProcess());
             if (!empty($xml_errors)) {
                 $this->_errors['static_xml'] = __('XML is invalid.');
             }
         }
     } elseif (is_numeric($fields['source'])) {
         if (strlen(trim($fields['max_records'])) == 0 || is_numeric($fields['max_records']) && $fields['max_records'] < 1) {
             if ($fields['paginate_results'] === 'yes') {
                 $this->_errors['max_records'] = __('A result limit must be set');
             }
         } elseif (!self::__isValidPageString($fields['max_records'])) {
             $this->_errors['max_records'] = __('Must be a valid number or parameter');
         }
         if (strlen(trim($fields['page_number'])) == 0 || is_numeric($fields['page_number']) && $fields['page_number'] < 1) {
             if ($fields['paginate_results'] === 'yes') {
                 $this->_errors['page_number'] = __('A page number must be set');
             }
         } elseif (!self::__isValidPageString($fields['page_number'])) {
             $this->_errors['page_number'] = __('Must be a valid number or parameter');
         }
         // See if a Provided Datasource is saved
     } elseif (!empty($providers)) {
         foreach ($providers as $providerClass => $provider) {
             if ($fields['source'] == call_user_func(array($providerClass, 'getSource'))) {
                 call_user_func_array(array($providerClass, 'validate'), array(&$fields, &$this->_errors));
                 break;
             }
             unset($providerClass);
         }
     }
     $classname = Lang::createHandle($fields['name'], 255, '_', false, true, array('@^[^a-z\\d]+@i' => '', '/[^\\w-\\.]/i' => ''));
     $rootelement = str_replace('_', '-', $classname);
     // Check to make sure the classname is not empty after handlisation.
     if (empty($classname) && !isset($this->_errors['name'])) {
         $this->_errors['name'] = __('Please ensure name contains at least one Latin-based character.', array($classname));
     }
     $file = DATASOURCES . '/data.' . $classname . '.php';
     $isDuplicate = false;
     $queueForDeletion = null;
     if ($this->_context[0] == 'new' && is_file($file)) {
         $isDuplicate = true;
     } elseif ($this->_context[0] == 'edit') {
         $existing_handle = $this->_context[1];
         if ($classname != $existing_handle && is_file($file)) {
             $isDuplicate = true;
         } elseif ($classname != $existing_handle) {
             $queueForDeletion = DATASOURCES . '/data.' . $existing_handle . '.php';
         }
     }
     // Duplicate
     if ($isDuplicate) {
         $this->_errors['name'] = __('A Data source with the name %s already exists', array('<code>' . $classname . '</code>'));
     }
     if (empty($this->_errors)) {
         $filters = array();
         $elements = null;
         $source = $fields['source'];
         $params = array('rootelement' => $rootelement);
         $about = array('name' => $fields['name'], 'version' => 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), 'release date' => DateTimeObj::getGMT('c'), 'author name' => Symphony::Author()->getFullName(), 'author website' => URL, 'author email' => Symphony::Author()->get('email'));
         // If there is a provider, get their template
         if ($providerClass) {
             $dsShell = file_get_contents(call_user_func(array($providerClass, 'getTemplate')));
         } else {
             $dsShell = file_get_contents($this->getTemplate('blueprints.datasource'));
         }
         // Author metadata
         self::injectAboutInformation($dsShell, $about);
         // Do dependencies, the template file must have <!-- CLASS NAME -->
         $dsShell = str_replace('<!-- CLASS NAME -->', $classname, $dsShell);
         // If there is a provider, let them do the prepartion work
         if ($providerClass) {
             $dsShell = call_user_func(array($providerClass, 'prepare'), $fields, $params, $dsShell);
         } else {
             switch ($source) {
                 case 'authors':
                     $extends = 'AuthorDatasource';
                     if (isset($fields['filter']['author'])) {
                         $filters = $fields['filter']['author'];
                     }
                     $elements = $fields['xml_elements'];
                     $params['order'] = $fields['order'];
                     $params['redirectonempty'] = $fields['redirect_on_empty'];
                     $params['redirectonforbidden'] = $fields['redirect_on_forbidden'];
                     $params['redirectonrequired'] = $fields['redirect_on_required'];
                     $params['requiredparam'] = trim($fields['required_url_param']);
                     $params['negateparam'] = trim($fields['negate_url_param']);
                     $params['paramoutput'] = $fields['param'];
                     $params['sort'] = $fields['sort'];
                     break;
                 case 'navigation':
                     $extends = 'NavigationDatasource';
                     if (isset($fields['filter']['navigation'])) {
                         $filters = $fields['filter']['navigation'];
                     }
                     $params['order'] = $fields['order'];
                     $params['redirectonempty'] = $fields['redirect_on_empty'];
                     $params['redirectonforbidden'] = $fields['redirect_on_forbidden'];
                     $params['redirectonrequired'] = $fields['redirect_on_required'];
                     $params['requiredparam'] = trim($fields['required_url_param']);
                     $params['negateparam'] = trim($fields['negate_url_param']);
                     break;
                 case 'static_xml':
                     $extends = 'StaticXMLDatasource';
                     $fields['static_xml'] = trim($fields['static_xml']);
                     if (preg_match('/^<\\?xml/i', $fields['static_xml']) == true) {
                         // Need to remove any XML declaration
                         $fields['static_xml'] = preg_replace('/^<\\?xml[^>]+>/i', null, $fields['static_xml']);
                     }
                     $params['static'] = sprintf('%s', trim($fields['static_xml']));
                     break;
                 default:
                     $extends = 'SectionDatasource';
                     $elements = $fields['xml_elements'];
                     if (is_array($fields['filter']) && !empty($fields['filter'])) {
                         $filters = array();
                         foreach ($fields['filter'] as $f) {
                             foreach ($f as $key => $val) {
                                 $filters[$key] = $val;
                             }
                         }
                     }
                     $params['order'] = $fields['order'];
                     $params['group'] = $fields['group'];
                     $params['paginateresults'] = $fields['paginate_results'];
                     $params['limit'] = $fields['max_records'];
                     $params['startpage'] = $fields['page_number'];
                     $params['redirectonempty'] = $fields['redirect_on_empty'];
                     $params['redirectonforbidden'] = $fields['redirect_on_forbidden'];
                     $params['redirectonrequired'] = $fields['redirect_on_required'];
                     $params['requiredparam'] = trim($fields['required_url_param']);
                     $params['negateparam'] = trim($fields['negate_url_param']);
                     $params['paramoutput'] = $fields['param'];
                     $params['sort'] = $fields['sort'];
                     $params['htmlencode'] = $fields['html_encode'];
                     $params['associatedentrycounts'] = $fields['associated_entry_counts'];
                     break;
             }
             $this->__injectVarList($dsShell, $params);
             $this->__injectIncludedElements($dsShell, $elements);
             self::injectFilters($dsShell, $filters);
             if (preg_match_all('@(\\$ds-[0-9a-z_\\.\\-]+)@i', $dsShell, $matches)) {
                 $dependencies = General::array_remove_duplicates($matches[1]);
                 $dsShell = str_replace('<!-- DS DEPENDENCY LIST -->', "'" . implode("', '", $dependencies) . "'", $dsShell);
             }
             $dsShell = str_replace('<!-- CLASS EXTENDS -->', $extends, $dsShell);
             $dsShell = str_replace('<!-- SOURCE -->', $source, $dsShell);
         }
         if ($this->_context[0] == 'new') {
             /**
              * Prior to creating the Datasource, the file path where it will be written to
              * is provided and well as the contents of that file.
              *
              * @delegate DatasourcePreCreate
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/datasources/'
              * @param string $file
              *  The path to the Datasource file
              * @param string $contents
              *  The contents for this Datasource as a string passed by reference
              * @param array $params
              *  An array of all the `$dsParam*` values
              * @param array $elements
              *  An array of all the elements included in this datasource
              * @param array $filters
              *  An associative array of all the filters for this datasource with the key
              *  being the `field_id` and the value the filter.
              * @param array $dependencies
              *  An array of dependencies that this datasource has
              */
             Symphony::ExtensionManager()->notifyMembers('DatasourcePreCreate', '/blueprints/datasources/', array('file' => $file, 'contents' => &$dsShell, 'params' => $params, 'elements' => $elements, 'filters' => $filters, 'dependencies' => $dependencies));
         } else {
             /**
              * Prior to editing a Datasource, the file path where it will be written to
              * is provided and well as the contents of that file.
              *
              * @delegate DatasourcePreEdit
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/datasources/'
              * @param string $file
              *  The path to the Datasource file
              * @param string $contents
              *  The contents for this Datasource as a string passed by reference
              * @param array $dependencies
              *  An array of dependencies that this datasource has
              * @param array $params
              *  An array of all the `$dsParam*` values
              * @param array $elements
              *  An array of all the elements included in this datasource
              * @param array $filters
              *  An associative array of all the filters for this datasource with the key
              *  being the `field_id` and the value the filter.
              */
             Symphony::ExtensionManager()->notifyMembers('DatasourcePreEdit', '/blueprints/datasources/', array('file' => $file, 'contents' => &$dsShell, 'dependencies' => $dependencies, 'params' => $params, 'elements' => $elements, 'filters' => $filters));
         }
         // Remove left over placeholders
         $dsShell = preg_replace(array('/<!--[\\w ]++-->/', '/(\\t+[\\r\\n]){2,}/', '/(\\r\\n){2,}/'), '$1', $dsShell);
         // Write the file
         if (!is_writable(dirname($file)) || !General::writeFile($file, $dsShell, Symphony::Configuration()->get('write_mode', 'file'), 'w', true)) {
             $this->pageAlert(__('Failed to write Data source to disk.') . ' ' . __('Please check permissions on %s.', array('<code>/workspace/data-sources</code>')), Alert::ERROR);
             // Write successful
         } else {
             if (function_exists('opcache_invalidate')) {
                 opcache_invalidate($file, true);
             }
             // Attach this datasources to pages
             $connections = $fields['connections'];
             ResourceManager::setPages(ResourceManager::RESOURCE_TYPE_DS, is_null($existing_handle) ? $classname : $existing_handle, $connections);
             // If the datasource has been updated and the name changed, then adjust all the existing pages that have the old datasource name
             if ($queueForDeletion) {
                 General::deleteFile($queueForDeletion);
                 // Update pages that use this DS
                 $pages = PageManager::fetch(false, array('data_sources', 'id'), array("\n                        `data_sources` REGEXP '[[:<:]]" . $existing_handle . "[[:>:]]'\n                    "));
                 if (is_array($pages) && !empty($pages)) {
                     foreach ($pages as $page) {
                         $page['data_sources'] = preg_replace('/\\b' . $existing_handle . '\\b/i', $classname, $page['data_sources']);
                         PageManager::edit($page['id'], $page);
                     }
                 }
             }
             if ($this->_context[0] == 'new') {
                 /**
                  * After creating the Datasource, the path to the Datasource file is provided
                  *
                  * @delegate DatasourcePostCreate
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/datasources/'
                  * @param string $file
                  *  The path to the Datasource file
                  */
                 Symphony::ExtensionManager()->notifyMembers('DatasourcePostCreate', '/blueprints/datasources/', array('file' => $file));
             } else {
                 /**
                  * After editing the Datasource, the path to the Datasource file is provided
                  *
                  * @delegate DatasourcePostEdit
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/datasources/'
                  * @param string $file
                  *  The path to the Datasource file
                  * @param string $previous_file
                  *  The path of the previous Datasource file in the case where a Datasource may
                  *  have been renamed. To get the handle from this value, see
                  *  `DatasourceManager::__getHandleFromFilename`
                  */
                 Symphony::ExtensionManager()->notifyMembers('DatasourcePostEdit', '/blueprints/datasources/', array('file' => $file, 'previous_file' => $queueForDeletion ? $queueForDeletion : null));
             }
             redirect(SYMPHONY_URL . '/blueprints/datasources/edit/' . $classname . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/');
         }
     }
 }
Esempio n. 10
0
    private static function showEditPhotoReportageForm($post, $error, $new = false)
    {
        $name = "Edit";
        $caption = "Modifica";
        if ($new) {
            $post = new Post($post);
            $name = "New";
            $caption = "Nuovo";
        }
        ?>
		<div class="title"><?php 
        echo $caption;
        ?>
 Photoreportage</div>
		<?php 
        if (is_array($error)) {
            ?>
		<div class="error"><?php 
            foreach ($error as $err) {
                ?>
			<p><?php 
                echo $err;
                ?>
</p>
			<?php 
            }
            ?>
</div>
		<?php 
        }
        if (!isset($_GET["phase"]) || count($error) != 0) {
            ?>
		<form name="<?php 
            echo $name;
            ?>
Post" action="?type=photoreportage&phase=2" method="post" enctype="multipart/form-data">
			<!--<p class="post_headline"><label>Occhiello:</label><br />
				<input class="post_headline" name="headline" value="<?php 
            echo Filter::decodeFilteredText($post->getHeadline());
            ?>
"/></p>-->
			<p class="title"><label>Titolo:</label><br/>
				<input class="post_title" name="title" value="<?php 
            echo Filter::decodeFilteredText($post->getTitle());
            ?>
"/></p>
			<p class="post_subtitle"><label>Sottotilolo:</label><br />
				<input class="post_subtitle" name="subtitle" value="<?php 
            echo Filter::decodeFilteredText($post->getSubtitle());
            ?>
"/></p>
			<p class="content">
				<label>Contenuto:</label><br/>
				<fieldset><legend>upload immagini</legend>
				<?php 
            for ($i = 0; $i < 10; $i++) {
                echo "<input type=\"file\"name=\"upfile{$i}\"></br>";
            }
            ?>
				</fieldset>
			</p>
			<p class="tags"><label>Tags:</label> 
				<input class="tags" id="post_tags_input" name="tags" value="<?php 
            echo Filter::decodeFilteredText($post->getTags());
            ?>
"/></p>
			<p class="categories"><label>Categorie:</label><br/><?php 
            $cat = array();
            if (trim($post->getCategories()) != "") {
                $cat = explode(", ", Filter::decodeFilteredText($post->getCategories()));
            }
            self::showCategoryTree($cat);
            ?>
			</p>
			<p class="<?php 
            echo trim($post->getPlace()) == "" ? "hidden" : "";
            ?>
"><label id="place_label">Posizione: <?php 
            echo $post->getPlace();
            ?>
</label></p>
			<input id="post_place" name="place" type="hidden" value="<?php 
            echo $post->getPlace();
            ?>
" />
			<input name="visible" type="hidden" value="true" />
			<input name="type" type="hidden" value="photoreportage" />
			<p class="submit"><input type="submit" value="Prosegui" /> 
				<input type="button" onclick="javascript:save();" value="Salva come bozza"/></p>
			<script type="text/javascript">
				function save() {
					document.<?php 
            echo $name;
            ?>
Post.visible.value = "no";
					document.<?php 
            echo $name;
            ?>
Post.submit();
				}
			</script>
			<?php 
            require_once 'manager/MapManager.php';
            MapManager::setCenterToMap($post->getPlace(), "map_canvas");
            ?>
		</form>
		<?php 
        } else {
            if (count($error) == 0) {
                ?>
			<fieldset><legend>Inserisci le descrizioni alle tue foto! </legend>
				<form name="<?php 
                echo $name;
                ?>
Post" action="?type=photoreportage&phase=3" method="post" enctype="multipart/form-data">
					<?php 
                for ($i = 0; $i < count($post->getContent()); $i++) {
                    $rs_array = $post->getContent();
                    $resource = ResourceManager::loadResource($rs_array[$i]);
                    $path = FileManager::appendToRootPath($resource->getPath());
                    $index = $resource->getID();
                    ?>
						<img src="<?php 
                    echo $path;
                    ?>
" width="200" height="100"/>
						<textarea name="<?php 
                    echo $index;
                    ?>
" rows="5" cols="40"></textarea> <!--textarea name is the ID of the corresponding resource-->
						<input type="hidden" name="<?php 
                    echo 'resourceID' . $i;
                    ?>
" value="<?php 
                    echo $index;
                    ?>
">
					<?php 
                }
                ?>
					<input type="hidden" name="numResources" value="<?php 
                echo count($post->getContent());
                ?>
"/>
					<input type="submit" value="Prosegui" /> 
				</form>
			</fieldset>
		<?php 
            }
        }
    }
Esempio n. 11
0
 /**
  * delete the resource by id
  * @param resource 对象
  * @return the resource delete result
  */
 public static function delete($resource_id)
 {
     $resource = ResourceManager::findById($resource_id);
     $resource->isDelete = 1;
     try {
         $ret = $resource->update();
     } catch (Exception $ex) {
         throw new Exception($ret . "删除资源失败" . $ex->getMessage());
     }
     return $ret;
 }
 public function __actionEdit()
 {
     if (array_key_exists('save', $_POST['action'])) {
         return $this->__formAction();
     } else {
         if (array_key_exists('delete', $_POST['action'])) {
             /**
              * Prior to deleting the Event file. Target file path is provided.
              *
              * @delegate EventPreDelete
              * @since Symphony 2.2
              * @param string $context
              * '/blueprints/events/'
              * @param string $file
              *  The path to the Event file
              */
             Symphony::ExtensionManager()->notifyMembers('EventPreDelete', '/blueprints/events/', array('file' => EVENTS . "/event." . $this->_context[1] . ".php"));
             if (!General::deleteFile(EVENTS . '/event.' . $this->_context[1] . '.php')) {
                 $this->pageAlert(__('Failed to delete %s.', array('<code>' . $this->_context[1] . '</code>')) . ' ' . __('Please check permissions on %s.', array('<code>/workspace/events</code>')), Alert::ERROR);
             } else {
                 $pages = ResourceManager::getAttachedPages(RESOURCE_TYPE_EVENT, $this->_context[1]);
                 foreach ($pages as $page) {
                     ResourceManager::detach(RESOURCE_TYPE_EVENT, $this->_context[1], $page['id']);
                 }
                 redirect(SYMPHONY_URL . '/blueprints/events/');
             }
         }
     }
 }
Esempio n. 13
0
$templatePath = "{$path}/temp/smarty/templates";
require "{$path}/Smarty/libs/Smarty.class.php";
require_once 'core/smarty.init.php';
require_once 'classes/Authenticate.php';
require_once 'classes/Connection.php';
require_once 'classes/Forum.php';
require_once 'classes/Evaluation.php';
require_once 'classes/Course.php';
require_once 'classes/ResourceManager.php';
ob_start();
session_start();
//echo $_SERVER["REMOTE_ADDR"];
$auth = new Authenticate();
$forum = new Forum();
$eval = new Evaluation();
$rMan = new ResourceManager();
$token = isset($_SESSION['token']) ? $_SESSION["token"] : "";
$id = isset($_SESSION['user_id']) ? $_SESSION["user_id"] : 0;
if (!$auth->isLogedin($token, $id)) {
    //Not logged in, send to login page.
    $msg = isset($_GET['loginerrorfeed']) ? $_GET["loginerrorfeed"] : "";
    $smarty->assign("message", $msg);
    $smarty->assign('user_id', $id);
    $smarty->assign('token', $token);
    $smarty->assign('profile', "You Do not have Active Session \n So no Profile to display!");
    if (isset($_GET["view"])) {
        $view = htmlspecialchars($_GET["view"]);
        if ($view == "registerView") {
            //take the person to register page
            if (isset($_GET["feedback"])) {
                $feedback = htmlentities(htmlspecialchars($_GET["feedback"]));
Esempio n. 14
0
 /**
  * This function increments the global $sql_queries variable
  *
  * @param string $sql The query that was just run
  */
 public function countQuery($sql = '')
 {
     if (self::$queryLimit != 0 && ++self::$queryCount > self::$queryLimit && (empty($GLOBALS['current_user']) || !is_admin($GLOBALS['current_user']))) {
         require_once 'include/resource/ResourceManager.php';
         if ($sql) {
             $GLOBALS['log']->fatal("Last query before failure:\n" . $sql);
         }
         $resourceManager = ResourceManager::getInstance();
         $resourceManager->notifyObservers('ERR_QUERY_LIMIT');
     }
 }
 /**
  * This function is called from the resources index when a user uses the
  * With Selected, or Apply, menu. The type of resource is given by
  * `$resource_type`. At this time the only two valid values,
  * `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`.
  *
  * The function handles 'delete', 'attach', 'detach', 'attach all',
  * 'detach all' actions.
  *
  * @param integer $resource_type
  *  Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`
  */
 public function __actionIndex($resource_type)
 {
     $manager = ResourceManager::getManagerFromType($resource_type);
     if (isset($_POST['action']) && is_array($_POST['action'])) {
         $checked = $_POST['items'] ? @array_keys($_POST['items']) : NULL;
         if (is_array($checked) && !empty($checked)) {
             if ($_POST['with-selected'] == 'delete') {
                 $canProceed = true;
                 foreach ($checked as $handle) {
                     $path = call_user_func(array($manager, '__getDriverPath'), $handle);
                     if (!General::deleteFile($path)) {
                         $folder = str_replace(DOCROOT, '', $path);
                         $folder = str_replace('/' . basename($path), '', $folder);
                         $this->pageAlert(__('Failed to delete %s.', array('<code>' . basename($path) . '</code>')) . ' ' . __('Please check permissions on %s', array('<code>' . $folder . '</code>')), Alert::ERROR);
                         $canProceed = false;
                     }
                 }
                 if ($canProceed) {
                     redirect(Administration::instance()->getCurrentPageURL());
                 }
             } else {
                 if (preg_match('/^(at|de)?tach-(to|from)-page-/', $_POST['with-selected'])) {
                     if (substr($_POST['with-selected'], 0, 6) == 'detach') {
                         $page = str_replace('detach-from-page-', '', $_POST['with-selected']);
                         foreach ($checked as $handle) {
                             ResourceManager::detach($resource_type, $handle, $page);
                         }
                     } else {
                         $page = str_replace('attach-to-page-', '', $_POST['with-selected']);
                         foreach ($checked as $handle) {
                             ResourceManager::attach($resource_type, $handle, $page);
                         }
                     }
                     if ($canProceed) {
                         redirect(Administration::instance()->getCurrentPageURL());
                     }
                 } else {
                     if (preg_match('/^(at|de)?tach-all-pages$/', $_POST['with-selected'])) {
                         $pages = PageManager::fetch(false, array('id'));
                         if (substr($_POST['with-selected'], 0, 6) == 'detach') {
                             foreach ($checked as $handle) {
                                 foreach ($pages as $page) {
                                     ResourceManager::detach($resource_type, $handle, $page['id']);
                                 }
                             }
                         } else {
                             foreach ($checked as $handle) {
                                 foreach ($pages as $page) {
                                     ResourceManager::attach($resource_type, $handle, $page['id']);
                                 }
                             }
                         }
                         redirect(Administration::instance()->getCurrentPageURL());
                     }
                 }
             }
         }
     }
 }
Esempio n. 16
0
 /**
  * This function increments the global $sql_queries variable
  */
 public function countQuery()
 {
     if (self::$queryLimit != 0 && ++self::$queryCount > self::$queryLimit && (empty($GLOBALS['current_user']) || !is_admin($GLOBALS['current_user']))) {
         require_once 'include/resource/ResourceManager.php';
         $resourceManager = ResourceManager::getInstance();
         $resourceManager->notifyObservers('ERR_QUERY_LIMIT');
     }
 }
Esempio n. 17
0
 /**
  * This function is called from the resources index when a user uses the
  * With Selected, or Apply, menu. The type of resource is given by
  * `$resource_type`. At this time the only two valid values,
  * `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`.
  *
  * The function handles 'delete', 'attach', 'detach', 'attach all',
  * 'detach all' actions.
  *
  * @param integer $resource_type
  *  Either `RESOURCE_TYPE_EVENT` or `RESOURCE_TYPE_DATASOURCE`
  * @throws Exception
  */
 public function __actionIndex($resource_type)
 {
     $manager = ResourceManager::getManagerFromType($resource_type);
     $checked = is_array($_POST['items']) ? array_keys($_POST['items']) : null;
     $context = Administration::instance()->getPageCallback();
     if (isset($_POST['action']) && is_array($_POST['action'])) {
         /**
          * Extensions can listen for any custom actions that were added
          * through `AddCustomPreferenceFieldsets` or `AddCustomActions`
          * delegates.
          *
          * @delegate CustomActions
          * @since Symphony 2.3.2
          * @param string $context
          *  '/blueprints/datasources/' or '/blueprints/events/'
          * @param array $checked
          *  An array of the selected rows. The value is usually the ID of the
          *  the associated object.
          */
         Symphony::ExtensionManager()->notifyMembers('CustomActions', $context['pageroot'], array('checked' => $checked));
         if (is_array($checked) && !empty($checked)) {
             if ($_POST['with-selected'] == 'delete') {
                 $canProceed = true;
                 foreach ($checked as $handle) {
                     $path = call_user_func(array($manager, '__getDriverPath'), $handle);
                     // Don't allow Extension resources to be deleted. RE: #2027
                     if (stripos($path, EXTENSIONS) === 0) {
                         continue;
                     } elseif (!General::deleteFile($path)) {
                         $folder = str_replace(DOCROOT, '', $path);
                         $folder = str_replace('/' . basename($path), '', $folder);
                         $this->pageAlert(__('Failed to delete %s.', array('<code>' . basename($path) . '</code>')) . ' ' . __('Please check permissions on %s', array('<code>' . $folder . '</code>')), Alert::ERROR);
                         $canProceed = false;
                     } else {
                         $pages = ResourceManager::getAttachedPages($resource_type, $handle);
                         foreach ($pages as $page) {
                             ResourceManager::detach($resource_type, $handle, $page['id']);
                         }
                     }
                 }
                 if ($canProceed) {
                     redirect(Administration::instance()->getCurrentPageURL());
                 }
             } elseif (preg_match('/^(at|de)?tach-(to|from)-page-/', $_POST['with-selected'])) {
                 if (substr($_POST['with-selected'], 0, 6) == 'detach') {
                     $page = str_replace('detach-from-page-', '', $_POST['with-selected']);
                     foreach ($checked as $handle) {
                         ResourceManager::detach($resource_type, $handle, $page);
                     }
                 } else {
                     $page = str_replace('attach-to-page-', '', $_POST['with-selected']);
                     foreach ($checked as $handle) {
                         ResourceManager::attach($resource_type, $handle, $page);
                     }
                 }
                 if ($canProceed) {
                     redirect(Administration::instance()->getCurrentPageURL());
                 }
             } elseif (preg_match('/^(at|de)?tach-all-pages$/', $_POST['with-selected'])) {
                 $pages = PageManager::fetch(false, array('id'));
                 if (substr($_POST['with-selected'], 0, 6) == 'detach') {
                     foreach ($checked as $handle) {
                         foreach ($pages as $page) {
                             ResourceManager::detach($resource_type, $handle, $page['id']);
                         }
                     }
                 } else {
                     foreach ($checked as $handle) {
                         foreach ($pages as $page) {
                             ResourceManager::attach($resource_type, $handle, $page['id']);
                         }
                     }
                 }
                 redirect(Administration::instance()->getCurrentPageURL());
             }
         }
     }
 }
 public function __viewEdit()
 {
     $this->setPageType('form');
     $fields = array("title" => null, "handle" => null, "parent" => null, "params" => null, "type" => null, "data_sources" => null);
     $existing = $fields;
     $nesting = Symphony::Configuration()->get('pages_table_nest_children', 'symphony') == 'yes';
     // Verify page exists:
     if ($this->_context[0] == 'edit') {
         if (!($page_id = (int) $this->_context[1])) {
             redirect(SYMPHONY_URL . '/blueprints/pages/');
         }
         $existing = PageManager::fetchPageByID($page_id);
         if (!$existing) {
             Administration::instance()->errorPageNotFound();
         } else {
             $existing['type'] = PageManager::fetchPageTypes($page_id);
         }
     }
     // Status message:
     if (isset($this->_context[2])) {
         $flag = $this->_context[2];
         $link_suffix = '';
         if (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
             $link_suffix = "?parent=" . $_REQUEST['parent'];
         } else {
             if ($nesting == true && isset($existing) && !is_null($existing['parent'])) {
                 $link_suffix = '?parent=' . $existing['parent'];
             }
         }
         switch ($flag) {
             case 'saved':
                 $this->pageAlert(__('Page updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/pages/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/pages/" accesskey="a">' . __('View all Pages') . '</a>', Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Page created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/pages/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/pages/" accesskey="a">' . __('View all Pages') . '</a>', Alert::SUCCESS);
         }
     }
     // Find values:
     if (isset($_POST['fields'])) {
         $fields = $_POST['fields'];
     } elseif ($this->_context[0] == 'edit') {
         $fields = $existing;
         if (!is_null($fields['type'])) {
             $fields['type'] = implode(', ', $fields['type']);
         }
         $fields['data_sources'] = preg_split('/,/i', $fields['data_sources'], -1, PREG_SPLIT_NO_EMPTY);
         $fields['events'] = preg_split('/,/i', $fields['events'], -1, PREG_SPLIT_NO_EMPTY);
     } elseif (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
         $fields['parent'] = $_REQUEST['parent'];
     }
     $title = $fields['title'];
     if (trim($title) == '') {
         $title = $existing['title'];
     }
     $this->setTitle(__($title ? '%1$s &ndash; %2$s &ndash; %3$s' : '%2$s &ndash; %3$s', array($title, __('Pages'), __('Symphony'))));
     $page_id = isset($page_id) ? $page_id : null;
     if (!empty($title)) {
         $template_name = $fields['handle'];
         $page_url = URL . '/' . PageManager::resolvePagePath($page_id) . '/';
         if ($existing['parent']) {
             $parents = PageManager::resolvePagePath($existing['parent']);
             $template_name = PageManager::createFilePath($parents, $fields['handle']);
         }
         $this->appendSubheading($title, array(Widget::Anchor(__('View Page'), $page_url, __('View Page on Frontend'), 'button', NULL, array('target' => '_blank', 'accesskey' => 'v')), Widget::Anchor(__('Edit Page Template'), SYMPHONY_URL . '/blueprints/pages/template/' . $template_name, __('Edit Page Template'), 'button', NULL, array('accesskey' => 't'))));
     } else {
         $this->appendSubheading(!empty($title) ? $title : __('Untitled'));
     }
     if (isset($page_id)) {
         $this->insertBreadcrumbsUsingPageIdentifier($page_id, false);
     } else {
         $_GET['parent'] = isset($_GET['parent']) ? $_GET['parent'] : null;
         $this->insertBreadcrumbsUsingPageIdentifier((int) $_GET['parent'], true);
     }
     // Title --------------------------------------------------------------
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings');
     $fieldset->appendChild(new XMLElement('legend', __('Page Settings')));
     $label = Widget::Label(__('Title'));
     $label->appendChild(Widget::Input('fields[title]', General::sanitize($fields['title'])));
     if (isset($this->_errors['title'])) {
         $label = Widget::Error($label, $this->_errors['title']);
     }
     $fieldset->appendChild($label);
     // Handle -------------------------------------------------------------
     $group = new XMLElement('div');
     $group->setAttribute('class', 'two columns');
     $column = new XMLElement('div');
     $column->setAttribute('class', 'column');
     $label = Widget::Label(__('URL Handle'));
     $label->appendChild(Widget::Input('fields[handle]', $fields['handle']));
     if (isset($this->_errors['handle'])) {
         $label = Widget::Error($label, $this->_errors['handle']);
     }
     $column->appendChild($label);
     // Parent ---------------------------------------------------------
     $label = Widget::Label(__('Parent Page'));
     $where = array(sprintf('id != %d', $page_id));
     $pages = PageManager::fetch(false, array('id'), $where, 'title ASC');
     $options = array(array('', false, '/'));
     if (!empty($pages)) {
         if (!function_exists('__compare_pages')) {
             function __compare_pages($a, $b)
             {
                 return strnatcasecmp($a[2], $b[2]);
             }
         }
         foreach ($pages as $page) {
             $options[] = array($page['id'], $fields['parent'] == $page['id'], '/' . PageManager::resolvePagePath($page['id']));
         }
         usort($options, '__compare_pages');
     }
     $label->appendChild(Widget::Select('fields[parent]', $options));
     $column->appendChild($label);
     $group->appendChild($column);
     // Parameters ---------------------------------------------------------
     $column = new XMLElement('div');
     $column->setAttribute('class', 'column');
     $label = Widget::Label(__('URL Parameters'));
     $label->appendChild(Widget::Input('fields[params]', $fields['params'], 'text', array('placeholder' => 'param1/param2')));
     $column->appendChild($label);
     // Type -----------------------------------------------------------
     $label = Widget::Label(__('Page Type'));
     $label->appendChild(Widget::Input('fields[type]', $fields['type']));
     if (isset($this->_errors['type'])) {
         $label = Widget::Error($label, $this->_errors['type']);
     }
     $column->appendChild($label);
     $tags = new XMLElement('ul');
     $tags->setAttribute('class', 'tags');
     $types = PageManager::fetchAvailablePageTypes();
     foreach ($types as $type) {
         $tags->appendChild(new XMLElement('li', $type));
     }
     $column->appendChild($tags);
     $group->appendChild($column);
     $fieldset->appendChild($group);
     $this->Form->appendChild($fieldset);
     // Events -------------------------------------------------------------
     $fieldset = new XMLElement('fieldset');
     $fieldset->setAttribute('class', 'settings');
     $fieldset->appendChild(new XMLElement('legend', __('Page Resources')));
     $group = new XMLElement('div');
     $group->setAttribute('class', 'two columns');
     $label = Widget::Label(__('Events'));
     $label->setAttribute('class', 'column');
     $events = ResourceManager::fetch(RESOURCE_TYPE_EVENT, array(), array(), 'name ASC');
     $options = array();
     if (is_array($events) && !empty($events)) {
         if (!isset($fields['events'])) {
             $fields['events'] = array();
         }
         foreach ($events as $name => $about) {
             $options[] = array($name, in_array($name, $fields['events']), $about['name']);
         }
     }
     $label->appendChild(Widget::Select('fields[events][]', $options, array('multiple' => 'multiple')));
     $group->appendChild($label);
     // Data Sources -------------------------------------------------------
     $label = Widget::Label(__('Data Sources'));
     $label->setAttribute('class', 'column');
     $datasources = ResourceManager::fetch(RESOURCE_TYPE_DS, array(), array(), 'name ASC');
     $options = array();
     if (is_array($datasources) && !empty($datasources)) {
         if (!isset($fields['data_sources'])) {
             $fields['data_sources'] = array();
         }
         foreach ($datasources as $name => $about) {
             $options[] = array($name, in_array($name, $fields['data_sources']), $about['name']);
         }
     }
     $label->appendChild(Widget::Select('fields[data_sources][]', $options, array('multiple' => 'multiple')));
     $group->appendChild($label);
     $fieldset->appendChild($group);
     $this->Form->appendChild($fieldset);
     // Controls -----------------------------------------------------------
     /**
      * After all Page related Fields have been added to the DOM, just before the
      * actions.
      *
      * @delegate AppendPageContent
      * @param string $context
      *  '/blueprints/pages/'
      * @param XMLElement $form
      * @param array $fields
      * @param array $errors
      */
     Symphony::ExtensionManager()->notifyMembers('AppendPageContent', '/blueprints/pages/', array('form' => &$this->Form, 'fields' => &$fields, 'errors' => $this->_errors));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Page'), 'submit', array('accesskey' => 's')));
     if ($this->_context[0] == 'edit') {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this page'), 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this page?')));
         $div->appendChild($button);
     }
     $this->Form->appendChild($div);
     if (isset($_REQUEST['parent']) && is_numeric($_REQUEST['parent'])) {
         $this->Form->appendChild(new XMLElement('input', NULL, array('type' => 'hidden', 'name' => 'parent', 'value' => $_REQUEST['parent'])));
     }
 }