/** * render the view * * @since 3.0.0 * * @return string */ public function render() { $output = Hook::trigger('loginFormStart'); $outputLegend = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('login')); if (Db::getSetting('recovery')) { $linkElement = new Html\Element(); $linkElement->init('a', ['href' => $this->_registry->get('parameterRoute') . 'login/recover']); $outputLegend = $linkElement->text($this->_language->get('recovery_question') . $this->_language->get('question_mark')); } $formElement = new Html\Form($this->_registry, $this->_language); $formElement->init(['form' => ['class' => 'rs-js-validate-form rs-form-default rs-form-login'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]); /* create the form */ $formElement->append('<fieldset>')->legend($outputLegend)->append('<ul><li>')->label('* ' . $this->_language->get('user'), ['for' => 'user'])->text(['autofocus' => 'autofocus', 'id' => 'user', 'name' => 'user', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required'])->append('</li><li>')->label('* ' . $this->_language->get('password'), ['for' => 'password'])->password(['id' => 'password', 'name' => 'password', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required'])->append('</li>'); if (Db::getSetting('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSetting('captcha') > 0) { $formElement->captcha('solution'); } $formElement->token()->submit(); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('loginFormEnd'); return $output; }
/** * render the title * * @since 3.0.0 * * @return string */ public function render() { $title = $this->_registry->get('metaTitle') ? $this->_registry->get('metaTitle') : Db::getSetting('title'); $description = $this->_registry->get('metaDescription') ? $this->_registry->get('metaDescription') : Db::getSetting('description'); $titleElement = new Html\Element(); return $titleElement->init('title')->text($title . Db::getSetting('divider') . $description)->render(); }
/** * render * * @since 3.0.0 * * @param string $url * @param array $optionArray * * @return string */ public static function render($url = null, $optionArray = []) { $counter = 0; $output = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', ['class' => self::$_configArray['className']['title']]); $linkElement = new Html\Element(); $linkElement->init('a', ['target' => '_blank']); $boxElement = new Html\Element(); $boxElement->init('div', ['class' => self::$_configArray['className']['box']]); /* load result */ $reader = new Reader(); $result = $reader->loadXML($url)->getObject(); $result = $result->entry ? $result->entry : $result->channel->item; /* process result */ if ($result) { foreach ($result as $value) { if ($counter++ < $optionArray['limit']) { $linkElement->attr('href', $value->link->attributes()->href ? $value->link->attributes()->href : $value->link)->text($value->title); /* collect output */ $output .= $titleElement->html($linkElement) . $boxElement->text($value->summary ? $value->summary : $value->description); } } } else { self::setNotification('error', Language::get('url_incorrect') . Language::get('point')); } return $output; }
/** * render * * @since 2.2.0 * * @param array $options * * @return string */ public static function render($options = array()) { $output = null; $counter = 0; $log = self::_log(); /* html elements */ $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', array('class' => self::$_config['className']['list'])); /* process log */ foreach ($log as $value) { /* break if limit reached */ if (++$counter > $options['limit']) { break; } $output .= '<li>'; $output .= $linkElement->attr(array('href' => Registry::get('rewriteRoute') . $value, 'title' => $value))->text($value); $output .= '</li>'; } /* collect list output */ if ($output) { $output = $listElement->html($output); } return $output; }
/** * render * * @since 2.2.0 * * @param mixed $src * @param array $options * * @return string */ public static function render($src = null, $options = array()) { $output = null; /* device related images */ if (is_array($src)) { /* process source */ foreach ($src as $key => $value) { if (in_array($key, self::$_config['device']) && Registry::get('my' . ucfirst($key))) { $src = $value; } } } /* collect output */ if (file_exists($src)) { $imageElement = new Html\Element(); $imageElement->init('img', array('alt' => $options['alt'], 'class' => self::$_config['className']['image'] . ' ' . $options['className'], 'src' => self::$_config['placeholder'])); /* collect output */ $output = $imageElement->copy()->attr('data-src', $src); /* placeholder */ if (self::$_config['placeholder']) { /* calculate image ratio */ $imageDimensions = getimagesize($src); $imageRatio = $imageDimensions[1] / $imageDimensions[0] * 100; /* placeholder */ $placeholderElement = new Html\Element(); $placeholderElement->init('div', array('class' => self::$_config['className']['placeholder'], 'style' => 'padding-bottom:' . $imageRatio . '%')); /* collect output */ $output = $placeholderElement->html($output); } /* noscript fallback */ $output .= '<noscript>' . $imageElement . '</noscript>'; } return $output; }
/** * commentReplace * * @since 2.2.0 */ public static function commentReplace() { $boxElement = new Html\Element(); $boxElement->init('div', ['id' => self::$_configArray['id']]); /* collect output */ $output = $boxElement; echo $output; }
/** * render * * @since 2.6.0 * * @param integer $lat * @param integer $lng * @param integer $zoom * * @return string */ public static function render($lat = 0, $lng = 0, $zoom = 1) { $mapElement = new Html\Element(); $mapElement->init('div', ['class' => self::$_configArray['className'], 'data-lat' => is_numeric($lat) ? $lat : null, 'data-lng' => is_numeric($lng) ? $lng : null, 'data-zoom' => is_numeric($zoom) ? $zoom : null]); /* collect output */ $output = $mapElement; return $output; }
/** * render the view * * @since 3.0.0 * * @param integer $moduleId identifier of the module * * @return string */ public function render($moduleId = null) { $output = Hook::trigger('adminModuleFormStart'); $module = Db::forTablePrefix('modules')->whereIdIs($moduleId)->findOne(); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-admin-title-content']); $titleElement->text($module->name); $linkElement = new Html\Element(); $linkElement->init('a'); $itemElement = new Html\Element(); $itemElement->init('li'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => 'rs-admin-js-list-tab rs-admin-list-tab']); $formElement = new AdminForm($this->_registry, $this->_language); $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . ($module->id ? 'admin/process/modules/' . $module->id : 'admin/process/modules'), 'class' => 'rs-admin-js-tab rs-admin-js-validate-form rs-admin-component-tab rs-admin-form-default rs-admin-fn-clearfix'], 'link' => ['cancel' => ['href' => $this->_registry->get('modulesEdit') && $this->_registry->get('modulesUninstall') ? $this->_registry->get('parameterRoute') . 'admin/view/modules' : $this->_registry->get('parameterRoute') . 'admin'], 'uninstall' => ['href' => $module->alias ? $this->_registry->get('parameterRoute') . 'admin/uninstall/modules/' . $module->alias . '/' . $this->_registry->get('token') : null]]]); /* docs directory */ $docsDirectory = new Directory(); $docsDirectory->init('modules/' . $module->alias . '/docs'); $docsDirectoryArray = $docsDirectory->getArray(); /* collect item output */ $tabCounter = 1; $tabRoute = $this->_registry->get('parameterRoute') . $this->_registry->get('fullRoute'); $outputItem = $itemElement->copy()->addClass('rs-admin-js-item-active rs-admin-item-active')->html($linkElement->copy()->attr('href', $tabRoute . '#tab-' . $tabCounter++)->text($this->_language->get('module'))); /* process directory */ foreach ($docsDirectoryArray as $value) { $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-' . $tabCounter++)->text(pathinfo($value, PATHINFO_FILENAME))); } /* collect item output */ $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-' . $tabCounter++)->text($this->_language->get('customize'))); $listElement->append($outputItem); /* create the form */ $tabCounter = 1; $formElement->append($listElement)->append('<div class="rs-admin-js-box-tab rs-admin-box-tab rs-admin-box-tab">')->append('<fieldset id="tab-' . $tabCounter++ . '" class="rs-admin-js-set-tab rs-admin-js-set-active rs-admin-set-tab rs-admin-set-active"><ul><li>')->label($this->_language->get('name'), ['for' => 'name'])->text(['autofocus' => 'autofocus', 'id' => 'name', 'name' => 'name', 'required' => 'required', 'value' => $module->name])->append('</li><li>')->label($this->_language->get('description'), ['for' => 'description'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-field-textarea rs-admin-field-small', 'id' => 'description', 'name' => 'description', 'rows' => 1, 'value' => $module->description])->append('</li></ul></fieldset>'); /* second tab */ if ($docsDirectoryArray) { /* process directory */ foreach ($docsDirectoryArray as $value) { $formElement->append('<fieldset id="tab-' . $tabCounter++ . '" class="rs-admin-js-set-tab rs-admin-set-tab">')->append(Template\Tag::partial('modules/' . $module->alias . '/docs/' . $value))->append('</fieldset>'); } } /* last tab */ $formElement->append('<fieldset id="tab-' . $tabCounter++ . '" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('status'), ['for' => 'status'])->select(Helper\Option::getToggleArray(), ['id' => 'status', 'name' => 'status', 'value' => intval($module->status)])->append('</li>'); if ($this->_registry->get('groupsEdit')) { $formElement->append('<li>')->label($this->_language->get('access'), ['for' => 'access'])->select(Helper\Option::getAccessArray('groups'), ['id' => 'access', 'name' => 'access[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getAccessArray('groups')), 'value' => $module->access])->append('</li>'); } $formElement->append('</ul></fieldset></div>')->token()->cancel(); if ($this->_registry->get('modulesUninstall')) { $formElement->uninstall(); } if ($this->_registry->get('modulesEdit')) { $formElement->save(); } /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('adminModuleFormEnd'); return $output; }
/** * render the view * * @since 3.0.0 * * @param integer $userId identifier of the user * * @return string */ public function render($userId = null) { $output = Hook::trigger('adminUserFormStart'); $user = Db::forTablePrefix('users')->whereIdIs($userId)->findOne(); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-admin-title-content']); $titleElement->text($user->name ? $user->name : $this->_language->get('user_new')); $linkElement = new Html\Element(); $linkElement->init('a'); $itemElement = new Html\Element(); $itemElement->init('li'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => 'rs-admin-js-list-tab rs-admin-list-tab']); $formElement = new AdminForm($this->_registry, $this->_language); $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . ($user->id ? 'admin/process/users/' . $user->id : 'admin/process/users'), 'class' => 'rs-admin-js-tab rs-admin-js-validate-form rs-admin-component-tab rs-admin-form-default rs-admin-fn-clearfix'], 'link' => ['cancel' => ['href' => $this->_registry->get('usersEdit') && $this->_registry->get('usersDelete') ? $this->_registry->get('parameterRoute') . 'admin/view/users' : $this->_registry->get('parameterRoute') . 'admin'], 'delete' => ['href' => $user->id ? $this->_registry->get('parameterRoute') . 'admin/delete/users/' . $user->id . '/' . $this->_registry->get('token') : null]]]); /* collect item output */ $tabRoute = $this->_registry->get('parameterRoute') . $this->_registry->get('fullRoute'); $outputItem = $itemElement->copy()->addClass('rs-admin-js-item-active rs-admin-item-active')->html($linkElement->copy()->attr('href', $tabRoute . '#tab-1')->text($this->_language->get('user'))); $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-2')->text($this->_language->get('general'))); if (!$user->id || $user->id > 1) { $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-3')->text($this->_language->get('customize'))); } $listElement->append($outputItem); /* create the form */ $formElement->append($listElement)->append('<div class="rs-admin-js-box-tab rs-admin-box-tab">')->append('<fieldset id="tab-1" class="rs-admin-js-set-tab rs-admin-js-set-active rs-admin-set-tab rs-admin-set-active"><ul><li>')->label($this->_language->get('name'), ['for' => 'name'])->text(['autofocus' => 'autofocus', 'id' => 'name', 'name' => 'name', 'required' => 'required', 'value' => $user->name])->append('</li>'); if (!$user->id) { $formElement->append('<li>')->label($this->_language->get('user'), ['for' => 'user'])->text(['id' => 'user', 'name' => 'user', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required', 'value' => $user->user])->append('</li>'); } $formElement->append('<li>')->label($this->_language->get('password'), ['for' => 'password'])->password(['id' => 'password', 'pattern' => '[a-zA-Z0-9]{1,30}', 'name' => 'password'])->append('</li><li>')->label($this->_language->get('password_confirm'), ['for' => 'password_confirm'])->password(['id' => 'password_confirm', 'pattern' => '[a-zA-Z0-9]{1,30}', 'name' => 'password_confirm'])->append('</li><li>')->label($this->_language->get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'required' => 'required', 'value' => $user->email])->append('</li><li>')->label($this->_language->get('description'), ['for' => 'description'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-field-textarea rs-admin-field-small', 'id' => 'description', 'name' => 'description', 'rows' => 1, 'value' => $user->description])->append('</li></ul></fieldset>')->append('<fieldset id="tab-2" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('language'), ['for' => 'language'])->select(Helper\Option::getLanguageArray(), ['id' => 'language', 'name' => 'language', 'value' => $user->language])->append('</li></ul></fieldset>'); /* last tab */ if (!$user->id || $user->id > 1) { $formElement->append('<fieldset id="tab-3" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('status'), ['for' => 'status'])->select(Helper\Option::getToggleArray(), ['id' => 'status', 'name' => 'status', 'value' => $user->id ? intval($user->status) : 1])->append('</li>'); if ($this->_registry->get('groupsEdit')) { $formElement->append('<li>')->label($this->_language->get('groups'), ['for' => 'groups'])->select(Helper\Option::getAccessArray('groups'), ['id' => 'groups', 'name' => 'groups[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getAccessArray('groups')), 'value' => $user->groups])->append('</li>'); } $formElement->append('</ul></fieldset>'); } $formElement->append('</div>')->token()->cancel(); if ($user->id) { if (($this->_registry->get('usersDelete') || $this->_registry->get('myId') === $user->id) && $user->id > 1) { $formElement->delete(); } if ($this->_registry->get('usersEdit') || $this->_registry->get('myId') === $user->id) { $formElement->save(); } } else { if ($this->_registry->get('usersNew')) { $formElement->create(); } } /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('adminUserFormEnd'); return $output; }
/** * render * * @since 2.2.0 * * @return string */ public static function render() { $output = null; $outputItem = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', array('class' => self::$_config['className']['title'])); $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', array('class' => self::$_config['className']['list'])); /* fetch articles */ $articles = Db::forTablePrefix('articles')->where('status', 1)->whereIn('language', array(Registry::get('language'), ''))->orderByDesc('category')->findArray(); /* process articles */ if (!$articles) { $error = Language::get('article_no') . Language::get('point'); } else { $accessValidator = new Validator\Access(); $accessDeny = 0; $lastCategory = 0; foreach ($articles as $value) { if ($accessValidator->validate($value['access'], Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) { $currentCategory = $value['category']; /* collect output */ if ($lastCategory != $currentCategory) { if ($lastCategory > 0) { $output .= $listElement->html($outputItem); $outputItem = null; } $output .= $titleElement->text($currentCategory < 1 ? Language::get('uncategorized') : Db::forTablePrefix('categories')->whereIdIs($currentCategory)->findOne()->title); } /* collect item output */ $outputItem .= '<li>'; $outputItem .= $linkElement->attr(array('href' => $value['category'] < 1 ? $value['alias'] : build_route('articles', $value['id']), 'title' => $value['description'] ? $value['description'] : $value['title']))->text($value['title']); $outputItem .= '</li>'; /* collect list output */ if (end($articles) === $value) { $output .= $listElement->html($outputItem); $outputItem = null; } $lastCategory = $currentCategory; } else { $accessDeny++; } } /* handle access */ if (count($articles) === $accessDeny) { $error = Language::get('access_no') . Language::get('point'); } } /* handle error */ if ($error) { $output = $listElement->html('<li>' . $error . '</li>'); } return $output; }
/** * commentsReplace * * @since 2.2.0 */ public static function commentsReplace() { $boxElement = new Html\Element(); $boxElement->init('div', array('id' => self::$_config['id'])); $scriptElement = new Html\Element(); $scriptElement->init('script', array('src' => self::$_config['url'])); /* collect output */ $output = $boxElement . $scriptElement; echo $output; }
/** * render the style * * @since 3.0.0 * * @return string */ public function render() { $output = null; /* html elements */ $styleElement = new Html\Element(); $styleElement->init('style'); /* collect inline */ if (self::$_inline) { $output .= $styleElement->copy()->text(self::$_inline); } $this->clear(); return $output; }
/** * render * * @since 2.2.0 * * @return string */ public static function render() { $output = null; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', ['class' => self::$_configArray['className']['title']]); $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => self::$_configArray['className']['list']]); /* query articles */ $articles = Db::forTablePrefix('articles')->where('status', 1)->whereLanguageIs(Registry::get('language'))->orderByDesc('date')->findMany(); /* process articles */ if (!$articles) { $error = Language::get('article_no') . Language::get('point'); } else { $accessValidator = new Validator\Access(); $accessDeny = 0; $lastDate = 0; foreach ($articles as $value) { if ($accessValidator->validate($value->access, Registry::get('myGroups')) === Validator\ValidatorInterface::PASSED) { $month = date('n', strtotime($value->date)); $year = date('Y', strtotime($value->date)); $currentDate = $month + $year; /* collect output */ if ($lastDate != $currentDate) { $output .= $titleElement->text(Language::get($month - 1, '_month') . ' ' . $year); } $lastDate = $currentDate; /* collect item output */ $outputItem = '<li>'; $outputItem .= $linkElement->attr(['href' => Registry::get('parameterRoute') . build_route('articles', $value->id), 'title' => $value->description ? $value->description : $value->title])->text($value->title); $outputItem .= '</li>'; /* collect list output */ $output .= $listElement->html($outputItem); } else { $accessDeny++; } } /* handle access */ if (count($articles) === $accessDeny) { $error = Language::get('access_no') . Language::get('point'); } } /* handle error */ if ($error) { $output = $listElement->html('<li>' . $error . '</li>'); } return $output; }
/** * render the view * * @since 3.0.0 * * @return string */ public function render() { $output = Hook::trigger('resetFormStart'); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('password_reset')); $formElement = new Html\Form($this->_registry, $this->_language); $formElement->init(['form' => ['class' => 'rs-js-validate-form rs-form-default rs-form-reset'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => true]); /* create the form */ $formElement->append('<fieldset>')->legend()->append('<li><ul>')->captcha('task')->append('</li></ul></fieldset>')->hidden(['name' => 'password', 'value' => $this->_registry->get('thirdParameter')])->hidden(['name' => 'id', 'value' => $this->_registry->get('thirdSubParameter')])->captcha('solution')->token()->submit(); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('resetFormEnd'); return $output; }
/** * render the view * * @param array $optionArray options of the form * * @since 3.0.0 * * @return string */ public function render($optionArray = []) { $output = Hook::trigger('installFormStart'); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('installation')); $formElement = new Html\Form($this->_registry, $this->_language); $formElement->init(['form' => ['class' => 'rs-js-accordion rs-js-validate-form rs-install-js-form rs-component-accordion rs-form-default rs-install-form-default'], 'button' => ['submit' => ['class' => 'rs-js-submit rs-button-default rs-is-large rs-is-full', 'name' => get_class()]]]); /* create the form */ $formElement->append('<fieldset class="rs-js-set-accordion rs-js-set-active rs-set-accordion rs-set-active">')->append('<legend class="rs-js-title-accordion rs-js-title-active rs-title-accordion rs-title-active">' . $this->_language->get('database_setup') . '</legend>')->append('<ul class="rs-js-box-accordion rs-js-box-active rs-box-accordion rs-box-active"><li>')->label($this->_language->get('type'), ['for' => 'db-type'])->select(Helper\Option::getDatabaseArray(), ['id' => 'db-type', 'name' => 'db-type', 'value' => $optionArray['dbType']])->append('</li><li>')->label($this->_language->get('host'), ['for' => 'db-host'])->text(['data-sqlite' => uniqid() . '.sqlite', 'data-mysql' => 'localhost', 'data-pgsql' => 'localhost', 'id' => 'db-host', 'name' => 'db-host', 'required' => 'required', 'value' => $optionArray['dbHost']])->append('</li><li>')->label($this->_language->get('name'), ['for' => 'db-name'])->text(['id' => 'db-name', 'name' => 'db-name', 'required' => 'required', 'value' => $optionArray['dbName']])->append('</li><li>')->label($this->_language->get('user'), ['for' => 'db-user'])->text(['id' => 'db-user', 'name' => 'db-user', 'required' => 'required', 'value' => $optionArray['dbUser']])->append('</li><li>')->label($this->_language->get('password'), ['for' => 'db-password'])->password(['id' => 'db-password', 'name' => 'db-password', 'value' => $optionArray['dbPassword']])->append('</li><li>')->label($this->_language->get('prefix'), ['for' => 'db-prefix'])->text(['id' => 'db-prefix', 'name' => 'db-prefix', 'value' => $optionArray['dbPrefix']])->append('</li></ul></fieldset>')->append('<fieldset class="rs-js-set-accordion rs-set-accordion">')->append('<legend class="rs-js-title-accordion rs-title-accordion">' . $this->_language->get('account_create') . '</legend>')->append('<ul class="rs-js-box-accordion rs-box-accordion"><li>')->label($this->_language->get('name'), ['for' => 'name'])->text(['id' => 'admin-name', 'name' => 'admin-name', 'required' => 'required', 'value' => $optionArray['adminName']])->append('</li><li>')->label($this->_language->get('user'), ['for' => 'admin-user'])->text(['id' => 'admin-user', 'name' => 'admin-user', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required', 'value' => $optionArray['adminUser']])->append('</li><li>')->label($this->_language->get('password'), ['for' => 'admin_password'])->password(['id' => 'admin-password', 'name' => 'admin-password', 'pattern' => '[a-zA-Z0-9]{1,30}', 'required' => 'required', 'value' => $optionArray['adminPassword']])->append('</li><li>')->label($this->_language->get('email'), ['for' => 'admin-email'])->email(['id' => 'admin-email', 'name' => 'admin-email', 'required' => 'required', 'value' => $optionArray['adminEmail']])->append('</li></ul></fieldset>')->hidden(['name' => 'db-salt', 'value' => sha1(uniqid())])->hidden(['name' => 'refresh-connection', 'value' => 1])->token()->submit($this->_language->get('install')); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('installFormEnd'); return $output; }
/** * render the view * * @since 3.0.0 * * @param integer $groupId identifier of the group * * @return string */ public function render($groupId = null) { $output = Hook::trigger('adminGroupFormStart'); $group = Db::forTablePrefix('groups')->whereIdIs($groupId)->findOne(); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-admin-title-content']); $titleElement->text($group->name ? $group->name : $this->_language->get('group_new')); $linkElement = new Html\Element(); $linkElement->init('a'); $itemElement = new Html\Element(); $itemElement->init('li'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => 'rs-admin-js-list-tab rs-admin-list-tab']); $formElement = new AdminForm($this->_registry, $this->_language); $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . ($group->id ? 'admin/process/groups/' . $group->id : 'admin/process/groups'), 'class' => 'rs-admin-js-tab rs-admin-js-validate-form rs-admin-component-tab rs-admin-form-default rs-admin-fn-clearfix'], 'link' => ['cancel' => ['href' => $this->_registry->get('groupsEdit') && $this->_registry->get('groupsDelete') ? $this->_registry->get('parameterRoute') . 'admin/view/groups' : $this->_registry->get('parameterRoute') . 'admin'], 'delete' => ['href' => $group->id ? $this->_registry->get('parameterRoute') . 'admin/delete/groups/' . $group->id . '/' . $this->_registry->get('token') : null]]]); /* collect item output */ $tabRoute = $this->_registry->get('parameterRoute') . $this->_registry->get('fullRoute'); $outputItem = $itemElement->copy()->addClass('rs-admin-js-item-active rs-admin-item-active')->html($linkElement->copy()->attr('href', $tabRoute . '#tab-1')->text($this->_language->get('group'))); if (!$group->id || $group->id > 1) { $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-2')->text($this->_language->get('access'))); $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-3')->text($this->_language->get('customize'))); } $listElement->append($outputItem); /* create the form */ $formElement->append($listElement)->append('<div class="rs-admin-js-box-tab rs-admin-box-tab rs-admin-box-tab">')->append('<fieldset id="tab-1" class="rs-admin-js-set-tab rs-admin-js-set-active rs-admin-set-tab rs-admin-set-active"><ul><li>')->label($this->_language->get('name'), ['for' => 'name'])->text(['autofocus' => 'autofocus', 'id' => 'name', 'name' => 'name', 'required' => 'required', 'value' => $group->name])->append('</li><li>')->label($this->_language->get('user'), ['for' => 'user'])->text(['id' => 'alias', 'name' => 'alias', 'pattern' => '[a-zA-Z0-9-]+', 'required' => 'required', 'value' => $group->alias])->append('</li><li>')->label($this->_language->get('description'), ['for' => 'description'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-field-textarea rs-admin-field-small', 'id' => 'description', 'name' => 'description', 'rows' => 1, 'value' => $group->description])->append('</li></ul></fieldset>'); /* second tab */ if (!$group->id || $group->id > 1) { $formElement->append('<fieldset id="tab-2" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('categories'), ['for' => 'categories'])->select(Helper\Option::getPermissionArray(), ['id' => 'categories', 'name' => 'categories[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getPermissionArray()), 'value' => $group->categories])->append('</li><li>')->label($this->_language->get('articles'), ['for' => 'articles'])->select(Helper\Option::getPermissionArray(), ['id' => 'articles', 'name' => 'articles[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getPermissionArray()), 'value' => $group->articles])->append('</li><li>')->label($this->_language->get('extras'), ['for' => 'extras'])->select(Helper\Option::getPermissionArray(), ['id' => 'extras', 'name' => 'extras[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getPermissionArray()), 'value' => $group->extras])->append('</li><li>')->label($this->_language->get('comments'), ['for' => 'comments'])->select(Helper\Option::getPermissionArray(), ['id' => 'comments', 'name' => 'comments[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getPermissionArray()), 'value' => $group->comments])->append('</li><li>')->label($this->_language->get('groups'), ['for' => 'groups'])->select(Helper\Option::getPermissionArray(), ['id' => 'groups', 'name' => 'groups[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getPermissionArray()), 'value' => $group->groups])->append('</li><li>')->label($this->_language->get('users'), ['for' => 'users'])->select(Helper\Option::getPermissionArray(), ['id' => 'users', 'name' => 'users[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getPermissionArray()), 'value' => $group->users])->append('</li><li>')->label($this->_language->get('modules'), ['for' => 'modules'])->select(Helper\Option::getPermissionArray('modules'), ['id' => 'modules', 'name' => 'modules[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getPermissionArray('modules')), 'value' => $group->modules])->append('</li><li>')->label($this->_language->get('settings'), ['for' => 'settings'])->select(Helper\Option::getPermissionArray('settings'), ['id' => 'settings', 'name' => 'settings[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getPermissionArray('settings')), 'value' => intval($group->settings)])->append('</li></ul></fieldset>')->append('<fieldset id="tab-3" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('filter'), ['for' => 'filter'])->select(Helper\Option::getToggleArray(), ['id' => 'filter', 'name' => 'filter', 'value' => $group->id ? $group->filter : 1])->append('</li><li>')->label($this->_language->get('status'), ['for' => 'status'])->select(Helper\Option::getToggleArray(), ['id' => 'status', 'name' => 'status', 'value' => $group->id ? intval($group->status) : 1])->append('</li></ul></fieldset>'); } $formElement->append('</div>')->token()->cancel(); if ($group->id) { if ($this->_registry->get('groupsDelete') && $group->id > 1) { $formElement->delete(); } if ($this->_registry->get('groupsEdit')) { $formElement->save(); } } else { if ($this->_registry->get('groupsNew')) { $formElement->create(); } } /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('adminGroupFormEnd'); return $output; }
/** * render the view * * @since 3.0.0 * * @return string */ public function render() { $output = Hook::trigger('adminSettingFormStart'); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-admin-title-content']); $titleElement->text($this->_language->get('settings')); $formElement = new AdminForm($this->_registry, $this->_language); $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . 'admin/update/settings', 'class' => 'rs-admin-js-accordion rs-admin-js-validate-form rs-admin-component-accordion rs-admin-form-default rs-admin-fn-clearfix'], 'button' => ['save' => ['name' => 'update']], 'link' => ['cancel' => ['href' => $this->_registry->get('parameterRoute') . 'admin']]]); /* create the form */ $formElement->append('<fieldset class="rs-admin-js-set-accordion rs-admin-js-set-active rs-admin-set-accordion rs-admin-set-active">')->append('<legend class="rs-admin-js-title-accordion rs-admin-js-title-active rs-admin-title-accordion rs-admin-title-active">' . $this->_language->get('general') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-js-box-active rs-admin-box-accordion rs-admin-box-accordion rs-admin-box-active"><li>')->label($this->_language->get('language'), ['for' => 'language'])->select(Helper\Option::getLanguageArray(), ['id' => 'language', 'name' => 'language', 'value' => Db::getSetting('language')])->append('</li><li>')->label($this->_language->get('template'), ['for' => 'template'])->select(Helper\Option::getTemplateArray(), ['id' => 'template', 'name' => 'template', 'value' => Db::getSetting('template')])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('metadata') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('title'), ['for' => 'title'])->text(['id' => 'title', 'name' => 'title', 'value' => Db::getSetting('title')])->append('</li><li>')->label($this->_language->get('author'), ['for' => 'author'])->text(['id' => 'author', 'name' => 'author', 'value' => Db::getSetting('author')])->append('</li><li>')->label($this->_language->get('copyright'), ['for' => 'copyright'])->text(['id' => 'copyright', 'name' => 'copyright', 'value' => Db::getSetting('copyright')])->append('</li><li>')->label($this->_language->get('description'), ['for' => 'description'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-field-textarea rs-admin-field-small', 'id' => 'description', 'name' => 'description', 'rows' => 1, 'value' => Db::getSetting('description')])->append('</li><li>')->label($this->_language->get('keywords'), ['for' => 'keywords'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-field-textarea rs-admin-field-small', 'id' => 'keywords', 'name' => 'keywords', 'rows' => 1, 'value' => Db::getSetting('keywords')])->append('</li><li>')->label($this->_language->get('robots'), ['for' => 'robots'])->select(Helper\Option::getRobotArray(), ['id' => 'robots', 'name' => 'robots', 'value' => filter_var(Db::getSetting('robots'), FILTER_VALIDATE_INT)])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('contact') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'value' => Db::getSetting('email')])->append('</li><li>')->label($this->_language->get('subject'), ['for' => 'subject'])->text(['id' => 'subject', 'name' => 'subject', 'value' => Db::getSetting('subject')])->append('</li><li>')->label($this->_language->get('notification'), ['for' => 'notification'])->select(Helper\Option::getToggleArray(), ['id' => 'notification', 'name' => 'notification', 'value' => intval(Db::getSetting('notification'))])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('formatting') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('charset'), ['for' => 'charset'])->text(['id' => 'charset', 'name' => 'charset', 'value' => Db::getSetting('charset')])->append('</li><li>')->label($this->_language->get('divider'), ['for' => 'divider'])->text(['id' => 'divider', 'name' => 'divider', 'value' => Db::getSetting('divider')])->append('</li><li>')->label($this->_language->get('time'), ['for' => 'time'])->select(Helper\Option::getTimeArray(), ['id' => 'time', 'name' => 'time', 'value' => Db::getSetting('time')])->append('</li><li>')->label($this->_language->get('date'), ['for' => 'date'])->select(Helper\Option::getDateArray(), ['id' => 'date', 'name' => 'date', 'value' => Db::getSetting('date')])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('contents') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('homepage'), ['for' => 'homepage'])->select(Helper\Option::getContentArray('articles'), ['id' => 'homepage', 'name' => 'homepage', 'value' => Db::getSetting('homepage')])->append('</li><li>')->label($this->_language->get('limit'), ['for' => 'limit'])->number(['id' => 'limit', 'name' => 'limit', 'value' => Db::getSetting('limit')])->append('</li><li>')->label($this->_language->get('order'), ['for' => 'order'])->select(Helper\Option::getOrderArray(), ['id' => 'order', 'name' => 'order', 'value' => Db::getSetting('order')])->append('</li><li>')->label($this->_language->get('pagination'), ['for' => 'pagination'])->select(Helper\Option::getToggleArray(), ['id' => 'pagination', 'name' => 'pagination', 'value' => intval(Db::getSetting('pagination'))])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('users') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('registration'), ['for' => 'registration'])->select(Helper\Option::getToggleArray(), ['id' => 'registration', 'name' => 'registration', 'value' => intval(Db::getSetting('registration'))])->append('</li><li>')->label($this->_language->get('verification'), ['for' => 'verification'])->select(Helper\Option::getToggleArray(), ['id' => 'verification', 'name' => 'verification', 'value' => intval(Db::getSetting('verification'))])->append('</li><li>')->label($this->_language->get('recovery'), ['for' => 'recovery'])->select(Helper\Option::getToggleArray(), ['id' => 'recovery', 'name' => 'recovery', 'value' => intval(Db::getSetting('recovery'))])->append('</li></ul></fieldset>')->append('<fieldset class="rs-admin-js-set-accordion rs-admin-set-accordion">')->append('<legend class="rs-admin-js-title-accordion rs-admin-title-accordion">' . $this->_language->get('security') . '</legend>')->append('<ul class="rs-admin-js-box-accordion rs-admin-box-accordion rs-admin-box-accordion"><li>')->label($this->_language->get('moderation'), ['for' => 'moderation'])->select(Helper\Option::getToggleArray(), ['id' => 'moderation', 'name' => 'moderation', 'value' => intval(Db::getSetting('moderation'))])->append('</li><li>')->label($this->_language->get('captcha'), ['for' => 'captcha'])->select(Helper\Option::getCaptchaArray(), ['id' => 'captcha', 'name' => 'captcha', 'value' => intval(Db::getSetting('captcha'))])->append('</li></ul></fieldset>')->token()->cancel()->save(); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('adminSettingFormEnd'); return $output; }
/** * render * * @since 2.6.0 * * @param string $directory * @param array $options * * @return string */ public static function render($directory = null, $options = null) { $output = null; $outputItem = null; /* html elements */ $imageElement = new Html\Element(); $imageElement->init('img', array('class' => self::$_config['className']['image'])); $linkElement = new Html\Element(); $linkElement->init('a'); $listElement = new Html\Element(); $listElement->init('ul', array('class' => self::$_config['className']['list'])); /* gallery directory */ $galleryDirectory = new Directory(); $galleryDirectory->init($directory, self::$_config['thumbDirectory']); $galleryDirectoryArray = $galleryDirectory->getArray(); /* adjust order */ if ($options['order'] === 'desc') { $galleryDirectoryArray = array_reverse($galleryDirectoryArray); } /* gallery data */ $galleryCounter = 0; $galleryTotal = count($galleryDirectoryArray); $galleryId = uniqid('gallery-'); /* remove thumbs */ if ($options['command'] === 'remove' || !$galleryTotal) { $galleryDirectory->remove(self::$_config['thumbDirectory']); } else { /* process directory */ foreach ($galleryDirectoryArray as $key => $value) { $imagePath = $directory . '/' . $value; $thumbPath = $directory . '/' . self::$_config['thumbDirectory'] . '/' . $value; /* create thumbs */ if ($options['command'] === 'create' || !is_file($thumbPath)) { self::_createThumb($value, $directory, $options); } /* image data */ $imageData = self::_getImageData($imagePath); /* collect item output */ $outputItem .= '<li>'; $outputItem .= $linkElement->copy()->attr(array('href' => $imagePath, 'data-counter' => ++$galleryCounter, 'data-total' => $galleryTotal, 'data-id' => $galleryId, 'data-artist' => array_key_exists('artist', $imageData) ? $imageData['artist'] : null, 'data-date' => array_key_exists('date', $imageData) ? $imageData['date'] : null, 'data-description' => array_key_exists('description', $imageData) ? $imageData['description'] : null))->html($imageElement->copy()->attr(array('src' => $thumbPath, 'alt' => array_key_exists('description', $imageData) ? $imageData['description'] : null))); $outputItem .= '</li>'; } $output = $listElement->attr('id', $galleryId)->html($outputItem); } return $output; }
/** * render the view * * @since 3.0.0 * * @param integer $articleId identifier of the article * * @return string */ public function render($articleId = null) { $output = Hook::trigger('adminArticleFormStart'); $article = Db::forTablePrefix('articles')->whereIdIs($articleId)->findOne(); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-admin-title-content']); $titleElement->text($article->title ? $article->title : $this->_language->get('article_new')); $linkElement = new Html\Element(); $linkElement->init('a'); $itemElement = new Html\Element(); $itemElement->init('li'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => 'rs-admin-js-list-tab rs-admin-list-tab']); $formElement = new AdminForm($this->_registry, $this->_language); $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . ($article->id ? 'admin/process/articles/' . $article->id : 'admin/process/articles'), 'class' => 'rs-admin-js-tab rs-admin-js-validate-form rs-admin-component-tab rs-admin-form-default rs-admin-fn-clearfix'], 'link' => ['cancel' => ['href' => $this->_registry->get('articlesEdit') && $this->_registry->get('articlesDelete') ? $this->_registry->get('parameterRoute') . 'admin/view/articles' : $this->_registry->get('parameterRoute') . 'admin'], 'delete' => ['href' => $article->id ? $this->_registry->get('parameterRoute') . 'admin/delete/articles/' . $article->id . '/' . $this->_registry->get('token') : null]]]); /* collect item output */ $tabRoute = $this->_registry->get('parameterRoute') . $this->_registry->get('fullRoute'); $outputItem = $itemElement->copy()->addClass('rs-admin-js-item-active rs-admin-item-active')->html($linkElement->copy()->attr('href', $tabRoute . '#tab-1')->text($this->_language->get('article'))); $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-2')->text($this->_language->get('general'))); $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-3')->text($this->_language->get('customize'))); $listElement->append($outputItem); /* create the form */ $formElement->append($listElement)->append('<div class="rs-admin-js-box-tab rs-admin-box-tab">')->append('<fieldset id="tab-1" class="rs-admin-js-set-tab rs-admin-js-set-active rs-admin-set-tab rs-admin-set-active"><ul><li>')->label($this->_language->get('title'), ['for' => 'title'])->text(['autofocus' => 'autofocus', 'class' => 'rs-admin-js-generate-alias-input rs-admin-field-default rs-admin-field-text', 'id' => 'title', 'name' => 'title', 'required' => 'required', 'value' => $article->title])->append('</li><li>')->label($this->_language->get('alias'), ['for' => 'alias'])->text(['class' => 'rs-admin-js-generate-alias-output rs-admin-field-default rs-admin-field-text', 'id' => 'alias', 'name' => 'alias', 'pattern' => '[a-zA-Z0-9-]+', 'required' => 'required', 'value' => $article->alias])->append('</li><li>')->label($this->_language->get('description'), ['for' => 'description'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-field-textarea rs-admin-field-small', 'id' => 'description', 'name' => 'description', 'rows' => 1, 'value' => $article->description])->append('</li><li>')->label($this->_language->get('keywords'), ['for' => 'keywords'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-js-generate-keyword-output rs-admin-field-textarea rs-admin-field-small', 'id' => 'keywords', 'name' => 'keywords', 'rows' => 1, 'value' => $article->keywords])->append('</li><li>')->label($this->_language->get('robots'), ['for' => 'robots'])->select(Helper\Option::getRobotArray(), ['id' => 'robots', 'name' => 'robots', 'value' => $article->id ? filter_var($article->robots, FILTER_VALIDATE_INT) : null])->append('</li><li>')->label($this->_language->get('text'), ['for' => 'text'])->textarea(['class' => 'rs-admin-js-auto-resize rs-admin-js-generate-keyword-input rs-admin-js-editor-textarea rs-admin-field-textarea', 'id' => 'text', 'name' => 'text', 'required' => 'required', 'value' => htmlspecialchars($article->text)])->append('</li></ul></fieldset>')->append('<fieldset id="tab-2" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('language'), ['for' => 'language'])->select(Helper\Option::getLanguageArray(), ['id' => 'language', 'name' => 'language', 'value' => $article->language])->append('</li><li>')->label($this->_language->get('template'), ['for' => 'template'])->select(Helper\Option::getTemplateArray(), ['id' => 'template', 'name' => 'template', 'value' => $article->template])->append('</li><li>')->label($this->_language->get('article_sibling'), ['for' => 'sibling'])->select(Helper\Option::getContentArray('articles', [intval($article->id)]), ['id' => 'sibling', 'name' => 'sibling', 'value' => intval($article->sibling)])->append('</li><li>')->label($this->_language->get('category'), ['for' => 'category'])->select(Helper\Option::getContentArray('categories'), ['id' => 'category', 'name' => 'category', 'value' => intval($article->category)])->append('</li></ul></fieldset>')->append('<fieldset id="tab-3" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('headline'), ['for' => 'headline'])->select(Helper\Option::getToggleArray(), ['id' => 'headline', 'name' => 'headline', 'value' => $article->id ? intval($article->headline) : 1])->append('</li><li>')->label($this->_language->get('byline'), ['for' => 'byline'])->select(Helper\Option::getToggleArray(), ['id' => 'byline', 'name' => 'byline', 'value' => $article->id ? intval($article->byline) : 1])->append('</li><li>')->label($this->_language->get('comments'), ['for' => 'comments'])->select(Helper\Option::getToggleArray(), ['id' => 'comments', 'name' => 'comments', 'value' => intval($article->comments)])->append('</li><li>')->label($this->_language->get('status'), ['for' => 'status'])->select(Helper\Option::getVisibleArray(), ['id' => 'status', 'name' => 'status', 'value' => $article->id ? intval($article->status) : 1])->append('</li><li>')->label($this->_language->get('rank'), ['for' => 'rank'])->number(['id' => 'rank', 'name' => 'rank', 'value' => $article->id ? intval($article->rank) : Db::forTablePrefix('articles')->max('rank') + 1])->append('</li>'); if ($this->_registry->get('groupsEdit')) { $formElement->append('<li>')->label($this->_language->get('access'), ['for' => 'access'])->select(Helper\Option::getAccessArray('groups'), ['id' => 'access', 'name' => 'access[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getAccessArray('groups')), 'value' => $article->access])->append('</li>'); } $formElement->append('<li>')->label($this->_language->get('date'), ['for' => 'date'])->datetime(['id' => 'date', 'name' => 'date', 'value' => $article->date ? $article->date : null])->append('</li></ul></fieldset></div>')->token()->cancel(); if ($article->id) { if ($this->_registry->get('articlesDelete')) { $formElement->delete(); } if ($this->_registry->get('articlesEdit')) { $formElement->save(); } } else { if ($this->_registry->get('articlesNew')) { $formElement->create(); } } /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('adminArticleFormEnd'); return $output; }
/** * render the view * * @since 3.0.0 * * @param integer $commentId identifier of the comment * * @return string */ public function render($commentId = null) { $output = Hook::trigger('adminCommentFormStart'); $comment = Db::forTablePrefix('comments')->whereIdIs($commentId)->findOne(); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-admin-title-content']); $titleElement->text($comment->author ? $comment->author : $this->_language->get('comment_new')); $linkElement = new Html\Element(); $linkElement->init('a'); $itemElement = new Html\Element(); $itemElement->init('li'); $listElement = new Html\Element(); $listElement->init('ul', ['class' => 'rs-admin-js-list-tab rs-admin-list-tab']); $formElement = new AdminForm($this->_registry, $this->_language); $formElement->init(['form' => ['action' => $this->_registry->get('parameterRoute') . ($comment->id ? 'admin/process/comments/' . $comment->id : 'admin/process/comments'), 'class' => 'rs-admin-js-tab rs-admin-js-validate-form rs-admin-component-tab rs-admin-form-default rs-admin-fn-clearfix'], 'link' => ['cancel' => ['href' => $this->_registry->get('commentsEdit') && $this->_registry->get('commentsDelete') ? $this->_registry->get('parameterRoute') . 'admin/view/comments' : $this->_registry->get('parameterRoute') . 'admin'], 'delete' => ['href' => $comment->id ? $this->_registry->get('parameterRoute') . 'admin/delete/comments/' . $comment->id . '/' . $this->_registry->get('token') : null]]]); /* collect item output */ $tabRoute = $this->_registry->get('parameterRoute') . $this->_registry->get('fullRoute'); $outputItem = $itemElement->copy()->addClass('rs-admin-js-item-active rs-admin-item-active')->html($linkElement->copy()->attr('href', $tabRoute . '#tab-1')->text($this->_language->get('comment'))); $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-2')->text($this->_language->get('general'))); $outputItem .= $itemElement->copy()->html($linkElement->copy()->attr('href', $tabRoute . '#tab-3')->text($this->_language->get('customize'))); $listElement->append($outputItem); /* create the form */ $formElement->append($listElement)->append('<div class="rs-admin-js-box-tab rs-admin-box-tab">')->append('<fieldset id="tab-1" class="rs-admin-js-set-tab rs-admin-js-set-active rs-admin-set-tab rs-admin-set-active"><ul><li>')->label('* ' . $this->_language->get('author'), ['for' => 'author'])->text(['id' => 'author', 'name' => 'author', 'readonly' => 'readonly', 'required' => 'required', 'value' => $comment->author ? $comment->author : $this->_registry->get('myName')])->append('</li><li>')->label('* ' . $this->_language->get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'readonly' => 'readonly', 'required' => 'required', 'value' => $comment->email ? $comment->email : $this->_registry->get('myEmail')])->append('</li><li>')->label($this->_language->get('url'), ['for' => 'url'])->url(['id' => 'url', 'name' => 'url', 'value' => $comment->url])->append('</li><li>')->label('* ' . $this->_language->get('text'), ['for' => 'text'])->textarea(['id' => 'text', 'name' => 'text', 'required' => 'required', 'value' => htmlspecialchars($comment->text)])->append('</li></ul></fieldset>')->append('<fieldset id="tab-2" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('language'), ['for' => 'language'])->select(Helper\Option::getLanguageArray(), ['id' => 'language', 'name' => 'language', 'value' => $comment->language])->append('</li><li>')->label($this->_language->get('article'), ['for' => 'article'])->select(Helper\Option::getContentArray('articles'), ['id' => 'article', 'name' => 'article', 'value' => intval($comment->article)])->append('</li></ul></fieldset>')->append('<fieldset id="tab-3" class="rs-admin-js-set-tab rs-admin-set-tab"><ul><li>')->label($this->_language->get('status'), ['for' => 'status'])->select(Helper\Option::getVisibleArray(), ['id' => 'status', 'name' => 'status', 'value' => $comment->id ? intval($comment->status) : 1])->append('</li><li>')->label($this->_language->get('rank'), ['for' => 'rank'])->number(['id' => 'rank', 'name' => 'rank', 'value' => $comment->id ? intval($comment->rank) : Db::forTablePrefix('comments')->max('rank') + 1])->append('</li>'); if ($this->_registry->get('groupsEdit')) { $formElement->append('<li>')->label($this->_language->get('access'), ['for' => 'access'])->select(Helper\Option::getAccessArray('groups'), ['id' => 'access', 'name' => 'access[]', 'multiple' => 'multiple', 'size' => count(Helper\Option::getAccessArray('groups')), 'value' => $comment->access])->append('</li>'); } $formElement->append('<li>')->label($this->_language->get('date'), ['for' => 'date'])->datetime(['id' => 'date', 'name' => 'date', 'value' => $comment->date ? $comment->date : null])->append('</li></ul></fieldset></div>')->token()->cancel(); if ($comment->id) { if ($this->_registry->get('commentsDelete')) { $formElement->delete(); } if ($this->_registry->get('commentsEdit')) { $formElement->save(); } } else { if ($this->_registry->get('commentsNew')) { $formElement->create(); } } /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('adminCommentFormEnd'); return $output; }
/** * render the meta * * @since 3.0.0 * * @return string */ public function render() { $output = null; /* html elements */ $metaElement = new Html\Element(); $metaElement->init('meta'); $collectionArray = self::$_collectionArray[self::$_namespace]; $collectionKeys = array_keys($collectionArray); $lastKey = end($collectionKeys); /* process collection */ foreach ($collectionArray as $key => $value) { $output .= $metaElement->copy()->attr($value); if ($key !== $lastKey) { $output .= PHP_EOL; } } $this->clear(); return $output; }
/** * render * * @since 3.0.0 * * @param string $alias * @param string $path * * @return string */ public static function render($alias = null, $path = null) { $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-preview', 'id' => $alias]); $linkElement = new Html\Element(); $linkElement->init('a', ['href' => Registry::get('secondParameter') === $alias ? Registry::get('parameterRoute') . 'preview#' . $alias : Registry::get('parameterRoute') . 'preview/' . $alias])->text(Registry::get('secondParameter') === $alias ? Language::get('back') : $alias); /* collect output */ $output = $titleElement->html($linkElement); $output .= Template\Tag::partial($path); return $output; }
/** * render the view * * @since 3.0.0 * * @param array $resultArray array for the result * * @return string */ public function render($resultArray = []) { $output = Hook::trigger('resultListStart'); $accessValidator = new Validator\Access(); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-result']); $listElement = new Html\Element(); $listElement->init('ol', ['class' => 'rs-list-result']); $itemElement = new Html\Element(); $itemElement->init('li'); $linkElement = new Html\Element(); $linkElement->init('a', ['class' => 'rs-link-result']); $textElement = new Html\Element(); $textElement->init('span', ['class' => 'rs-text-result-date']); /* process result */ foreach ($resultArray as $table => $result) { $outputItem = null; if ($result) { /* collect item output */ foreach ($result as $value) { if ($accessValidator->validate($result->access, $this->_registry->get('myGroups')) === Validator\ValidatorInterface::PASSED) { $textDate = date(Db::getSetting('date'), strtotime($value->date)); $linkElement->attr('href', $this->_registry->get('parameterRoute') . build_route($table, $value->id))->text($value->title ? $value->title : $value->author); $textElement->text($textDate); $outputItem .= $itemElement->html($linkElement . $textElement); } } /* collect output */ if ($outputItem) { $titleElement->text($this->_language->get($table)); $listElement->html($outputItem); $output .= $titleElement . $listElement; } } } $output .= Hook::trigger('resultListEnd'); return $output; }
/** * render * * @since 2.2.0 * * @param string $url * * @return string */ public static function render($url = null) { $output = null; if ($url) { /* html elements */ $linkElement = new Html\Element(); $linkElement->init('a', ['target' => '_blank']); $listElement = new Html\Element(); $listElement->init('ul', ['class' => self::$_configArray['className']['list']]); /* process network */ foreach (self::$_configArray['network'] as $key => $value) { $output .= '<li>'; $output .= $linkElement->attr(['class' => self::$_configArray['className']['link'] . ' ' . $value['className'], 'data-height' => $value['height'], 'data-type' => $key, 'data-width' => $value['width'], 'href' => $value['url'] . $url])->text($key); $output .= '</li>'; } /* collect list output */ if ($output) { $output = $listElement->html($output); } } return $output; }
/** * render the view * * @since 3.0.0 * * @param integer $articleId identifier of the article * * @return string */ public function render($articleId = null) { $output = Hook::trigger('commentFormStart'); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('comment_new')); $formElement = new Html\Form($this->_registry, $this->_language); $formElement->init(['button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]); /* create the form */ $formElement->append('<fieldset>')->legend()->append('<ul><li>')->label('* ' . $this->_language->get('author'), ['for' => 'author'])->text(['id' => 'author', 'name' => 'author', 'readonly' => $this->_registry->get('myName') ? 'readonly' : null, 'required' => 'required', 'value' => $this->_registry->get('myName')])->append('</li><li>')->label('* ' . $this->_language->get('email'), ['for' => 'email'])->email(['id' => 'email', 'name' => 'email', 'readonly' => $this->_registry->get('myEmail') ? 'readonly' : null, 'required' => 'required', 'value' => $this->_registry->get('myEmail')])->append('</li><li>')->label($this->_language->get('url'), ['for' => 'url'])->url(['id' => 'url', 'name' => 'url'])->append('</li><li>')->label('* ' . $this->_language->get('text'), ['for' => 'text'])->textarea(['class' => 'rs-js-auto-resize rs-js-editor-textarea rs-field-textarea', 'id' => 'text', 'name' => 'text', 'required' => 'required'])->append('</li>'); if (Db::getSetting('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSetting('captcha') > 0) { $formElement->captcha('solution'); } $formElement->hidden(['name' => 'article', 'value' => $articleId])->token()->submit()->reset(); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('commentFormEnd'); return $output; }
/** * render the view * * @since 3.0.0 * * @return string */ public function render() { $output = Hook::trigger('recoverFormStart'); /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h2', ['class' => 'rs-title-content'])->text($this->_language->get('recovery')); $formElement = new Html\Form($this->_registry, $this->_language); $formElement->init(['form' => ['class' => 'rs-js-validate-form rs-form-default rs-form-recover'], 'button' => ['submit' => ['name' => get_class()]]], ['captcha' => Db::getSetting('captcha') > 0]); /* create the form */ $formElement->append('<fieldset>')->legend($this->_language->get('recovery_request') . $this->_language->get('point'))->append('<ul><li>')->label('* ' . $this->_language->get('email'), ['for' => 'email'])->email(['autofocus' => 'autofocus', 'id' => 'email', 'name' => 'email', 'required' => 'required'])->append('</li>'); if (Db::getSetting('captcha') > 0) { $formElement->append('<li>')->captcha('task')->append('</li>'); } $formElement->append('</ul></fieldset>'); if (Db::getSetting('captcha') > 0) { $formElement->captcha('solution'); } $formElement->token()->submit(); /* collect output */ $output .= $titleElement . $formElement; $output .= Hook::trigger('recoverFormEnd'); return $output; }
/** * render * * @since 2.3.0 * * @param string $url * @param array $options * * @return string */ public static function render($url = null, $options = array()) { $output = null; $counter = 0; /* html elements */ $titleElement = new Html\Element(); $titleElement->init('h3', array('class' => self::$_config['className']['title'])); $linkElement = new Html\Element(); $linkElement->init('a', array('target' => '_blank')); $boxElement = new Html\Element(); $boxElement->init('div', array('class' => self::$_config['className']['box'])); /* get contents */ $contents = file_get_contents($url); if ($contents) { $feed = new SimpleXMLElement($contents); $result = $feed->entry ? $feed->entry : $feed->channel->item; /* process result */ foreach ($result as $value) { /* break if limit reached */ if (++$counter > $options['limit']) { break; } /* handle feed type */ $url = $value->link['href'] ? (string) $value->link['href'] : (string) $value->link; $text = $value->summary ? $value->summary : $value->description; /* url */ if ($url) { $linkElement->attr('href', $url)->text($value->title); } else { $linkElement = $value->title; } /* collect output */ $output .= $titleElement->html($linkElement) . $boxElement->text($text); } } return $output; }
/** * render * * @since 2.2.0 * * @param mixed $file * @param array $optionArray * * @return string */ public static function render($file = null, $optionArray = []) { $output = null; /* device related images */ if (is_array($file)) { /* process source */ foreach ($file as $key => $value) { if (in_array($key, self::$_configArray['device']) && Registry::get('my' . ucfirst($key))) { $file = $value; } } } /* collect output */ if (file_exists($file)) { $imageElement = new Html\Element(); $imageElement->init('img', ['alt' => $optionArray['alt'], 'class' => self::$_configArray['className']['image'], 'src' => self::$_configArray['placeholder']]); /* collect image output */ $output = $imageElement->copy()->addClass($optionArray['className'])->attr('data-src', $file); /* placeholder */ if (self::$_configArray['placeholder']) { /* calculate image ratio */ $imageDimensions = getimagesize($file); $imageRatio = $imageDimensions[1] / $imageDimensions[0] * 100; /* placeholder */ $placeholderElement = new Html\Element(); $placeholderElement->init('div', ['class' => self::$_configArray['className']['placeholder'], 'style' => 'padding-bottom:' . $imageRatio . '%']); /* collect output */ $output = $placeholderElement->html($output); } /* noscript fallback */ $output .= '<noscript>' . $imageElement . '</noscript>'; } else { self::setNotification('error', Language::get('file_not_found') . Language::get('colon') . ' ' . $file . Language::get('point')); } return $output; }
/** * testClear * * @since 3.0.0 */ public function testClear() { /* setup */ $element = new Html\Element(); $element->init('a'); /* expect and actual */ $expect = '<a></a>'; $actual = $element->text('test')->clear(); /* compare */ $this->assertEquals($expect, $actual); }
/** * render * * @since 2.2.0 * * @param string $alias * @param string $path * * @return string */ public static function render($alias = null, $path = null) { $titleElement = new Html\Element(); $titleElement->init('h2', array('class' => 'title_content', 'title' => $alias)); $linkElement = new Html\Element(); $linkElement->init('a', array('href' => Registry::get('secondParameter') === $alias ? null : Registry::get('rewriteRoute') . 'preview/' . $alias, 'title' => $alias)); /* collect output */ $output = $titleElement->html($linkElement->text($alias)); $output .= Template::partial($path); return $output; }