function onBeforeWrite() { parent::onBeforeWrite(); if (!$this->SortOrder && $this->ModuleAreaID && ($modules = ContentModule::get()->filter(array('ModuleAreaID' => $this->ModuleAreaID)))) { $this->SortOrder = $modules->max('SortOrder') + 1; } }
/** * Action for the module, finds the appropriate module and passes the request handling on * @return mixed */ public function m($request = null) { if (!$request) { $request = $this->owner->request; } if ($request) { if (($urlSegment = $request->param('ID')) && ($moduleAction = $request->param('OtherID'))) { $request->shift(2); $module = ContentModule::get()->filter('URLSegment', $urlSegment)->first(); if ($module && $module->hasMethod($moduleAction)) { $response = $module->{$moduleAction}(); if (is_subclass_of($response, 'RequestHandler') && !$response instanceof Form) { return $response->handleRequest($request, new DataModel()); } return $response; } } else { if ($urlSegment = $request->param('ID')) { //default index action $request->shift(1); $module = ContentModule::get()->filter('URLSegment', $urlSegment)->first(); if ($module && $module->hasMethod('index')) { $return = $module->index(); if (is_subclass_of($return, 'RequestHandler')) { $return = $return->handleRequest(); } //ajax request the module handles the response if ($this->owner->request->isAjax()) { return $return; } //for normal request, the module can change its state, but the request is handled by the page return $this->owner->index(); } } } $this->owner->redirect($this->owner->Link()); } else { if (($urlSegment = $this->owner->request->param('ID')) && ($moduleAction = $this->owner->request->param('OtherID'))) { $module = ContentModule::get()->filter('URLSegment', $urlSegment)->first(); if ($module && $module->hasMethod($moduleAction)) { return $module->{$moduleAction}(); } } else { if ($urlSegment = $this->owner->request->param('ID')) { //default index action $module = ContentModule::get()->filter('URLSegment', $urlSegment)->first(); if ($module && $module->hasMethod('index')) { $return = $module->index(); //ajax request the module handles the response if ($this->owner->request->isAjax()) { return $return; } //for normal request, the module can change its state, but the request is handled by the page return $this->owner->index(); } } } $this->owner->redirect($this->owner->Link()); } }
function __construct($settings) { parent::__construct(); $this->name = "<name>{$settings['name']}</name>"; $this->icon = "<icon>{$settings['icon']}</icon>"; $this->head = $settings['head'] != '' ? "<head>{$settings['head']}</head>" : ''; $this->foot = $settings['foot'] != '' ? "<foot>{$settings['foot']}</foot>" : ''; //non xml-vars $this->feeds = $settings['feeds'] != '' ? $settings['feeds'] : ''; // var_dump($this->feeds); // Omnomnomnom if (isset($_REQUEST['feedcookie'])) { $this->cookies = ''; foreach ($_REQUEST as $feed => $val) { if ($val == 'on') { $this->cookies .= str_replace('_', ' ', $feed) . ','; } // echo($feed . ' => ' . $val .' ' ); } setcookie('feeds', $this->cookies, time() + 60 * 60 * 24 * 7 * 4 * 6); } else { if (isset($_COOKIE['feeds'])) { $this->cookies = $_COOKIE['feeds']; } setcookie('feeds', $this->cookies, time() + 60 * 60 * 24 * 7 * 4 * 6); // Six months expiry time } $this->getFeeds(); }
function __construct($settings) { parent::__construct(); $this->configPath = '../mapdata/uumap.xml'; $this->name = "<name>{$settings['name']}</name>"; $this->icon = isset($settings['icon']) ? "<icon>{$settings['icon']}</icon>" : ''; $this->head = isset($settings['head']) ? "<head>{$settings['head']}</head>" : ''; }
function run() { $inline_edit =& get_reason_inline_editing($this->page_id); if ($inline_edit->available_for_module($this)) { $this->run_editable(); } else parent::run(); }
public function onBeforeWrite() { parent::onBeforeWrite(); if (!$this->ResizeWidth) { $this->ResizeWidth = self::$default_width; } if (!$this->ResizeHeight) { $this->ResizeHeight = self::$default_height; } }
function __construct($settings) { parent::__construct(); $this->name = isset($settings['name']) ? "<name>{$settings['name']}</name>" : ''; $this->icon = isset($settings['icon']) ? "<icon>{$settings['icon']}</icon>" : ''; $this->head = isset($settings['head']) ? "<head>{$settings['head']}</head>" : ''; $this->body = isset($settings['body']) ? "<body>{$settings['body']}</body>" : ''; $this->foot = isset($settings['foot']) ? "<foot>{$settings['foot']}</foot>" : ''; $this->body = str_replace('-bpar-', '<p>', $this->body); $this->body = str_replace('-epar-', '</p>', $this->body); }
function __construct($settings) { parent::__construct(); $this->name = "<name>{$settings['name']}</name>"; $this->icon = "<icon>{$settings['icon']}</icon>"; $this->head = $settings['head'] != '' ? "<head>{$settings['head']}</head>" : ''; $this->foot = $settings['foot'] != '' ? "<foot>{$settings['foot']}</foot>" : ''; // $this->body = ($settings['feed'] != '')? // "<body>$settings[feed]</body>": ''; //non xml-vars $this->feed = $settings['feed'] != '' ? "{$settings['feed']}" : ''; $this->type = $settings['type'] != '' ? "{$settings['type']}" : ''; @$this->getFeed(); }
function __construct($settings) { parent::__construct(); $this->name = isset($settings['name']) ? "<name>{$settings['name']}</name>" : ''; $this->icon = isset($settings['icon']) ? "<icon>{$settings['icon']}</icon>" : ''; $this->head = isset($settings['head']) ? "<head>{$settings['head']}</head>" : ''; $this->names = isset($settings['body']) ? $settings['body']['person'] : ''; $this->foot = isset($settings['foot']) ? "<foot>{$settings['foot']}</foot>" : ''; $this->body = "<body>"; foreach ($this->names as $name) { $this->body .= "<item>" . $name . "</item>"; } $this->body .= "</body>"; }
/** * Parse the template * @return string */ public function generate() { if (TL_MODE == 'BE') { // create new backend template $objTemplate = new \BackendTemplate('be_include'); // get all include elements $objElements = \ContentModel::findBy('module', $this->module, array('order' => 'id')); // prepare include breadcrumbs $includes = array(); // go throuch each include element while ($objElements->next()) { // get the parent article $objArticle = \ArticleModel::findByPk($objElements->pid); if ($objArticle === null) { continue; } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { continue; } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // css classes for list $classes = array(); if ($objElements->id == $this->id) { $classes[] = 'self'; } if ($objElements->invisible) { $classes[] = 'hidden'; } // create breadcrumb $includes[] = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN), 'class' => implode(' ', $classes)); } // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } // add CSS $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS; // return info + content return $objTemplate->parse() . parent::generate(); } // return content only return parent::generate(); }
function __construct($settings) { parent::__construct(); $this->settings = $settings; // FIXME: failout when a setting is not set $this->name = isset($settings['name']) && $settings['name'] != '' ? "<name>{$settings['name']}</name>" : ''; $this->icon = isset($settings['icon']) && $settings['icon'] != '' ? "<icon>{$settings['icon']}</icon>" : ''; $this->head = isset($settings['head']) && $settings['head'] != '' ? "<head>{$settings['head']}</head>" : ''; $this->contentXML = <<<XML <section> <timeedit> <view> {$this->name} {$this->icon} {$this->head} </view> </timeedit> </section> XML; }
/** * unset connection * * unsets connection with seminar * @access public * @param string $seminar_id seminar-id * @return boolean successful */ function unsetConnection($seminar_id) { global $connected_cms, $messages; $connected_cms[$this->cms_type]->soap_client->setCachingStatus(false); if ($this->getObjectId() != false) { $connected_cms[$this->cms_type]->soap_client->deleteObject($this->getId()); } return parent::unsetConnection($seminar_id); $messages["error"] .= _("Die Zuordnung konnte nicht entfernt werden."); return false; }
/** * constructor * * init class. * @access public * @param string $module_id module-id * @param string $module_type module-type * @param string $cms_type system-type */ function PmWikiContentModule($module_id = "", $module_type, $cms_type) { parent::ContentModule($module_id, $module_type, $cms_type); $this->link = $GLOBALS['connected_cms'][$this->cms_type]->ABSOLUTE_PATH_ELEARNINGMODULES . $this->id . "/"; $this->client = WebserviceClient::instance($this->link . '?' . $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['URL_PARAMS'], $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['WEBSERVICE_CLASS']); }
public function onBeforeWrite() { parent::onBeforeWrite(); //default title if (!$this->Title) { $class = get_class($this); $objects = DataObject::get($class); $this->Title = singleton($class)->i18n_singular_name() . ' ' . ($objects->count() + 1); } if (!$this->URLSegment) { $this->URLSegment = URLSegmentFilter::create()->filter($this->Title); } else { if ($this->isChanged('URLSegment')) { $this->URLSegment = URLSegmentFilter::create()->filter($this->URLSegment); } } if ($this->isChanged('URLSegment') && ($original = $this->URLSegment)) { //make sure it is unique $safe = false; $counter = 1; while (!$safe) { $counter++; if (ContentModule::get()->filter(array('URLSegment' => $this->URLSegment, 'ID' => $this->ID))->first()) { $this->URLSegment = $original . '-' . $counter; } else { $safe = true; } } } }
public function PublishedContentModules() { return ContentModule::get()->filter(array('ModularPageID' => $this->ID, 'Published' => 1))->sort('SortOrder'); }
public function requireDefaultRecords() { parent::requireDefaultRecords(); //fix up pages which just used the parent $modules = RelatedPagesModule::get(); if ($modules && $modules->count()) { foreach ($modules as $module) { if ($module->UseChildren && !$module->TopLevelPageID) { //lookup page which has this module $pageID = DB::query('SELECT "PageID" FROM "Page_ContentModules" WHERE "ContentModuleID" = ' . $module->ID)->value(); if ($pageID) { $module->TopLevelPageID = $pageID; $module->write(); $module->publish('Stage', 'Live'); } } } } }
/** * Handles actions on fields for the module (e.g. uploadfield) * Expects the name of the field to be in the ID param (in the form ContentModule[ModuleID][FieldName], * and the action to be in the OtherID param */ public function modulefield() { if ($fieldName = $this->request->param('ID')) { $matches = array(); if (preg_match('/ContentModule\\[([0-9]{1,})\\]/i', $fieldName, $matches)) { $moduleID = $matches[1]; $module = ContentModule::get()->byID($moduleID); if ($module) { //get original field name $matches2 = array(); preg_match('/ContentModule\\[[0-9]{1,}\\]\\[([a-zA-Z0-9]{1,})\\]/i', $fieldName, $matches2); $originalFieldName = !empty($matches2[1]) ? $matches2[1] : ''; //composite field /*if (strpos($fieldName, '[')) { $openingBracket = strpos($fieldName, '[') - 1; $closingBracket = strpos($fieldName, ']') - 1; $fieldName = substr($fieldName, 0, $openingBracket); $subFieldName = substr($fieldName, $openingBracket + 2, $closingBracket - $openingBracket + 2); echo $fieldName . ' ' . $subFieldName;exit; }*/ //find the field $fields = $module->EditFields()->dataFields(); if ($fields) { foreach ($fields as $field) { if ($field->getName() == $fieldName) { //setup field name(s) if ($field->hasMethod('setContentModuleNames')) { $field->setContentModuleNames($originalFieldName, $fieldName); } else { $field->setName($originalFieldName); } //set record if required if ($field->hasMethod('setRecord')) { $field->setRecord($module); } return $field; //check if there is a url handler for this action /* $handlers = $field->stat('url_handlers'); if ($handlers && !empty($handlers[$action])) { return $field->{$handlers[$action]}($this->request); } else if ($field->hasMethod($action)) { return $field->{$action}($this->request); }*/ } } } } } } return $this->httpError(404); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab('Root.Main', array(new TextField('ContentTitle', 'Content Title'), new HtmlEditorField('Text'))); return $fields; }
/** * set connection * * sets connection with seminar * @access public * @param string $seminar_id seminar-id * @return boolean successful */ function setConnection($seminar_id) { global $connected_cms, $messages; $write_permission = Request::option("write_permission"); $crs_id = ObjectConnections::getConnectionModuleId($seminar_id, "crs", $this->cms_type); $connected_cms[$this->cms_type]->soap_client->setCachingStatus(false); $connected_cms[$this->cms_type]->soap_client->clearCache(); // Check, ob Kurs in ILIAS gelöscht wurde if ($crs_id != false and $connected_cms[$this->cms_type]->soap_client->getObjectByReference($crs_id) == false) { ObjectConnections::unsetConnection($seminar_id, $crs_id, "crs", $this->cms_type); $messages["info"] .= _("Der zugeordnete ILIAS-Kurs (ID {$crs_id}) existiert nicht mehr. Ein neuer Kurs wird angelegt.") . "<br>"; $crs_id = false; } $crs_id == $connected_cms[$this->cms_type]->createCourse($seminar_id); if ($crs_id == false) { return false; } $ref_id = $this->getId(); if (Request::get("copy_object") == "1") { $connected_cms[$this->cms_type]->soap_client->user_type = 'user'; $ref_id = $connected_cms[$this->cms_type]->soap_client->copyObject($this->id, $crs_id); $connected_cms[$this->cms_type]->soap_client->user_type = 'admin'; } else { $ref_id = $connected_cms[$this->cms_type]->soap_client->addReference($this->id, $crs_id); } if (!$ref_id) { $messages["error"] .= _("Zuordnungs-Fehler: Objekt konnte nicht angelegt werden."); return false; } $local_roles = $connected_cms[$this->cms_type]->soap_client->getLocalRoles($crs_id); $member_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray(array(OPERATION_VISIBLE, OPERATION_READ)); $admin_operations = $connected_cms[$this->cms_type]->permissions->getOperationArray(array(OPERATION_VISIBLE, OPERATION_READ, OPERATION_WRITE, OPERATION_DELETE)); $admin_operations_no_delete = $connected_cms[$this->cms_type]->permissions->getOperationArray(array(OPERATION_VISIBLE, OPERATION_READ, OPERATION_WRITE)); $admin_operations_readonly = $connected_cms[$this->cms_type]->permissions->getOperationArray(array(OPERATION_VISIBLE, OPERATION_READ, OPERATION_DELETE)); foreach ($local_roles as $key => $role_data) { // check only if local role is il_crs_member, -tutor or -admin if (strpos($role_data["title"], "il_crs_") === 0) { if (strpos($role_data["title"], 'il_crs_member') === 0) { $operations = $write_permission == "autor" ? $admin_operations_no_delete : $member_operations; } elseif (strpos($role_data["title"], 'il_crs_tutor') === 0) { $operations = $write_permission == "tutor" || $write_permission == "autor" ? $admin_operations : $admin_operations_readonly; } elseif (strpos($role_data["title"], 'il_crs_admin') === 0) { $operations = $write_permission == "dozent" || $write_permission == "tutor" || $write_permission == "autor" ? $admin_operations : $admin_operations_readonly; } else { continue; } $connected_cms[$this->cms_type]->soap_client->revokePermissions($role_data["obj_id"], $ref_id); $connected_cms[$this->cms_type]->soap_client->grantPermissions($operations, $role_data["obj_id"], $ref_id); } } if ($ref_id) { $this->setId($ref_id); return ContentModule::setConnection($seminar_id); } else { $messages["error"] .= _("Die Zuordnung konnte nicht gespeichert werden."); } return false; }
public function __construct($settings) { parent::__construct(); $this->name = "<name>{$settings['name']}</name>"; $this->icon = "<icon>{$settings['icon']}</icon>"; $this->head = "<head>{$settings['head']}</head>"; $this->settings = $settings; $this->ldap = new LDAP($settings['hosturl'], $settings['hostport'], $settings['basedn'], $settings['ldapattribs'], $settings['maxetoget']); //FIXME only for testing with many replies? $this->numToShow = (int) $settings['numtoshow']; if (isset($_REQUEST['numtoshow'])) { $this->numToShow = strip_tags($_REQUEST['numtoshow']); } if (isset($_REQUEST['page'])) { $this->page = '<page><value>' . strip_tags($_REQUEST['page']) . '</value></page>'; } // Used by javascript JS knows instance name for separation if (isset($_REQUEST['empsearchstring'])) { $this->searchString = strip_tags($_REQUEST['empsearchstring']); $this->searchString = trim($this->searchString); $this->searchString = preg_replace('/\\s+/', ' ', $this->searchString); mb_internal_encoding("UTF-8"); mb_regex_encoding("UTF-8"); $this->searchString = mb_strtolower($this->searchString); $this->searchString = mb_ereg_replace('[^' . $this->alwdChars . ']', '', $this->searchString); } //Uses instance name('name') for instance separation when not using js. if (isset($_REQUEST[$settings['name']])) { $this->searchString = strip_tags($_REQUEST[$settings['name']]); $this->searchString = trim($this->searchString); $this->searchString = preg_replace('/\\s+/', ' ', $this->searchString); mb_internal_encoding("UTF-8"); mb_regex_encoding("UTF-8"); $this->searchString = mb_strtolower($this->searchString); $this->searchString = mb_ereg_replace('[^' . $this->alwdChars . ']', '', $this->searchString); } $this->nonEmptySearchStr = $this->searchString != ''; //Default form. if ($this->nonEmptySearchStr) { $formValue = '<value>' . $this->searchString . '</value>'; } else { $formValue = ''; } $this->form = <<<FORM <form> <name>{$settings['name']}</name> <action></action> <method>get</method> {$formValue} {$this->page} <empbutton> <type>submit</type> <value>Sök</value> </empbutton> </form> FORM; $this->ajaxForm = <<<FORM <ajaxform> <name>{$settings['name']}</name> <action></action> <method>get</method> {$formValue} {$this->page} <ajaxempbutton> <type>submit</type> <value>Sök</value> </ajaxempbutton> </ajaxform> FORM; }
$module2->title = "Published Links"; $module2->orientation = LEFT; $module1 = new ShowContentModule($contents); $module1->title = "Community Content"; $module3 = new LinkModule($links['myself']); $module3->mode = PRI; $module3->block_type = 'Homepage'; $module3->title = "My Links"; $module3->orientation = LEFT; $module4 = new GroupModule($group_details); $module4->block_type = "GroupList"; $module4->title = "GroupList"; $module5 = new GroupModule($contents); $module5->block_type = "GroupCategory"; $module5->title = "GroupCategory"; $module6 = new ContentModule($contents); $module6->title = "Community blog Content"; print $header->fetch(); print $module2->render(); print '<div style="float:left; margin-left:10px;">'; print $module1->render(); print $module4->render(); print $module5->render(); print $module6->render(); print '</div>'; print '<div style="float:left; margin-left:10px;">'; print $module3->render(); print '</div>'; ?> </body> </html>
/** * Populates an array of classes in the CMS * which allows the user to change the page type. * * @return SS_List */ public function ModuleTypes() { $classes = ContentModule::content_module_types(); $result = new ArrayList(); foreach ($classes as $instance) { $class = $instance->class; if ($instance instanceof HiddenClass) { continue; } if (!$instance->canCreate()) { continue; } // skip this type if it is restricted if ($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) { continue; } $addAction = $instance->i18n_singular_name(); // Get description (convert 'Page' to 'SiteTree' for correct localization lookups) $description = _t($class . '.DESCRIPTION'); if (!$description) { $description = $instance->uninherited('description'); } $result->push(new ArrayData(array('ClassName' => $class, 'AddAction' => $addAction, 'Description' => $description, 'IconURL' => $instance->stat('icon'), 'Title' => singleton($class)->i18n_singular_name()))); } $result = $result->sort('AddAction'); return $result; }
/** * Returns the ContentModules sorted * * @return DataList */ public function SortedContentModules() { return ContentModule::get()->innerJoin('Page_ContentModules', '"ContentModule"."ID" = "Page_ContentModules"."ContentModuleID"')->where("\"Page_ContentModules\".\"PageID\" = '{$this->owner->ID}'")->sort('"Sort" ASC'); }