/**
  * Lists all Articlecomment models.
  * @return mixed
  */
 public function actionIndex()
 {
     $list = '';
     $post = Yii::$app->request->post();
     if ($post['id']) {
         $mod = new Query();
         $comment = $mod->select(['a.id', 'a.parentId', 'a.articleId', 'a.content', 'a.createTime', 'b.username'])->from('articlecomment as a')->leftJoin('user as b', 'a.userId = b.id')->where(['commentId' => $post['id']])->orderBy(['createTime' => 'DESC', 'id' => 'DESC'])->createCommand()->queryAll();
         if ($comment) {
             foreach ($comment as $v) {
                 $content = '回复@' . Articlecomment::getCommentByParId($v['parentId']) . ':' . $v['content'];
                 $ahtml = html::a(html::tag("i", "", ["class" => "fa fa-thumbs-o-up"]) . html::tag("span", "回复"), ["/main/viewart", "id" => $v["articleId"], "parId" => $v['id']]);
                 $list .= '<div class="infos small-comment' . $post['id'] . '" style="border:1px solid;">
                         	<div class="media-body markdown-reply content-body">
                         		<p>' . $content . '</p>
                         		<span class="opts pull-right">
                         			<a class="author" >' . $v["username"] . '</a>
                         			•
                         			<addr title="' . $v["createTime"] . '">' . Html::tag("span", Yii::$app->formatter->asRelativeTime($v["createTime"])) . '</addr>
                         			' . $ahtml . '
                                 </span>
                         	</div>
                         </div>';
             }
         }
     }
     $result = array('success' => true, 'message' => $list);
     echo json_encode($result);
     die;
     return $this->renderAjax('index', ['success' => true, 'message' => '']);
 }
Example #2
0
 /**
  * This callback function adds a box below the message content
  * if there is a vcard attachment available
  */
 function html_output($p)
 {
     $attach_script = false;
     $icon = 'plugins/vcard_attachments/' . $this->local_skin_path() . '/vcard_add_contact.png';
     foreach ($this->vcard_parts as $part) {
         $vcards = rcube_vcard::import($this->message->get_part_content($part));
         // successfully parsed vcards?
         if (empty($vcards)) {
             continue;
         }
         // remove part's body
         if (in_array($part, $this->vcard_bodies)) {
             $p['content'] = '';
         }
         $style = 'margin:0.5em 1em; padding:0.2em 0.5em; border:1px solid #999; ' . 'border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; width: auto';
         foreach ($vcards as $idx => $vcard) {
             $display = $vcard->displayname;
             if ($vcard->email[0]) {
                 $display .= ' <' . $vcard->email[0] . '>';
             }
             // add box below messsage body
             $p['content'] .= html::p(array('style' => $style), html::a(array('href' => "#", 'onclick' => "return plugin_vcard_save_contact('" . JQ($part . ':' . $idx) . "')", 'title' => $this->gettext('addvcardmsg')), html::img(array('src' => $icon, 'style' => "vertical-align:middle"))) . ' ' . html::span(null, Q($display)));
         }
         $attach_script = true;
     }
     if ($attach_script) {
         $this->include_script('vcardattach.js');
     }
     return $p;
 }
Example #3
0
 /**
  * Common actions.
  * 
  * @param  int    $productID 
  * @access public
  * @return void
  */
 public function commonAction($productID)
 {
     $this->loadModel('product');
     $this->view->product = $this->product->getById($productID);
     $this->view->position[] = html::a($this->createLink('product', 'browse', "productID={$this->view->product->id}"), $this->view->product->name);
     $this->product->setMenu($this->product->getPairs(), $productID);
 }
Example #4
0
 /**
  * @return string An error message suitable for inclusion in the task log
  */
 static function check_index()
 {
     list($remaining) = search::stats();
     if ($remaining) {
         site_status::warning(t('Your search index needs to be updated.  <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__")))), "search_index_out_of_date");
     }
 }
Example #5
0
File: ajax.php Project: azuya/Wi3
 public function action_addFolder()
 {
     $properties = array();
     $properties["owner"] = Wi3::inst()->sitearea->auth->user;
     $properties["adminright"] = Wi3::inst()->sitearea->auth->user->username;
     $properties["title"] = "Nieuwe map";
     $properties["type"] = "folder";
     $properties["created"] = time();
     $properties["filename"] = $properties["created"];
     // needs to be unique
     $settings = array();
     if (isset($_POST["refid"]) and !empty($_POST["refid"]) and isset($_POST["location"]) and !empty($_POST["location"])) {
         $settings["under"] = (int) preg_replace("/[^0-9]/", "", $_POST["refid"]);
     }
     // Add it
     $folder = Wi3::inst()->sitearea->files->add($properties, $settings);
     if ($folder) {
         // Remove cache of everything, since we do not know how this change affects the site
         Wi3::inst()->cache->removeAll();
         $li = html::anchor($folder->id, $folder->title);
         if ($folder->lft == 1 and $folder->rgt == 2) {
             // The new folder is the only folder there is. For the javascript menu to work properly, we need to reload the page.
             echo json_encode(array("scriptsbefore" => array("reload" => "window.location.reload();")));
         } else {
             echo json_encode(array("alert" => "map is aangemaakt", "scriptsafter" => array("adminarea.currentTree().addNode('treeItem_" . $folder->id . "','" . addslashes($li) . "')")));
         }
     } else {
         echo json_encode(array("alert" => "map kon NIET aangemaakt worden"));
     }
 }
 function __construct()
 {
     parent::__construct("feed");
     /* Set feed ID and self link. */
     $this->id(html::specialchars(url::abs_current()));
     $this->link()->rel("self")->href(url::abs_current());
 }
 function init()
 {
     $this->rcmail = rcmail::get_instance();
     $this->out = html::tag('div', array('style' => 'font-size: 12px; text-align: justify; position: absolute; margin-left: auto; left: 50%; margin-left: -250px; width: 500px;'), html::tag('h3', null, 'Welcome to MyRoundcube Plugins - Plugin Manager Installer') . html::tag('span', null, 'Please ' . html::tag('a', array('href' => $this->svn), 'download') . ' Plugin Manager package and upload the entire package to your Roundcube\'s plugin folder.' . html::tag('br') . html::tag('br') . ' If you are prompted to overwrite <i>"./plugins/plugin_manager"</i> please do so.') . html::tag('br') . html::tag('br') . html::tag('div', array('style' => 'display: inline; float: left'), html::tag('a', array('href' => 'javascript:void(0)', 'onclick' => 'document.location.href=\'./\''), $this->gettext('done'))));
     $this->register_handler('plugin.body', array($this, 'download'));
     $this->rcmail->output->send('plugin');
 }
 /**
  * Callback function used to build mailto: links around e-mail strings
  *
  * This also adds an onclick-handler to open the Rouncube compose message screen on such links
  *
  * @param array Matches result from preg_replace_callback
  * @return int Index of saved string value
  * @see rcube_string_replacer::mailto_callback()
  */
 public function mailto_callback($matches)
 {
     $href = $matches[1];
     $suffix = $this->parse_url_brackets($href);
     $i = $this->add(html::a(array('href' => 'mailto:' . $href, 'onclick' => "return " . rcmail_output::JS_OBJECT_NAME . ".command('compose','" . rcube::JQ($href) . "',this)"), rcube::Q($href)) . $suffix);
     return $i >= 0 ? $this->get_replacement($i) : '';
 }
Example #9
0
 private function postLine()
 {
     $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
     switch ($this->rs->post_status) {
         case 1:
             $img_status = sprintf($img, __('published'), 'check-on.png');
             break;
         case 0:
             $img_status = sprintf($img, __('unpublished'), 'check-off.png');
             break;
         case -1:
             $img_status = sprintf($img, __('scheduled'), 'scheduled.png');
             break;
         case -2:
             $img_status = sprintf($img, __('pending'), 'check-wrn.png');
             break;
     }
     $protected = '';
     if ($this->rs->post_password) {
         $protected = sprintf($img, __('protected'), 'locker.png');
     }
     $selected = '';
     if ($this->rs->post_selected) {
         $selected = sprintf($img, __('selected'), 'selected.png');
     }
     $attach = '';
     $nb_media = $this->rs->countMedia();
     if ($nb_media > 0) {
         $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
         $attach = sprintf($img, sprintf($attach_str, $nb_media), 'attach.png');
     }
     $res = '<tr class="line' . ($this->rs->post_status != 1 ? ' offline' : '') . '"' . ' id="p' . $this->rs->post_id . '">';
     $res .= '<td class="nowrap">' . form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()) . '</td>' . '<td class="maximal"><a href="' . $this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '">' . html::escapeHTML($this->rs->post_title) . '</a></td>' . '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . '</td>' . '<td class="nowrap">' . $this->rs->user_id . '</td>' . '<td class="nowrap">' . $this->rs->nb_comment . '</td>' . '<td class="nowrap">' . $this->rs->nb_trackback . '</td>' . '<td class="nowrap status">' . $img_status . ' ' . $selected . ' ' . $protected . ' ' . $attach . '</td>' . '</tr>';
     return $res;
 }
 /**
  * Callback function when HTML page is rendered
  * We'll add an overlay box here.
  */
 function render_page($p)
 {
     if ($_SESSION['plugin.newuserdialog'] && $p['template'] == 'mail') {
         $this->add_texts('localization');
         $rcmail = rcmail::get_instance();
         $identity = $rcmail->user->get_identity();
         $identities_level = intval($rcmail->config->get('identities_level', 0));
         // compose user-identity dialog
         $table = new html_table(array('cols' => 2));
         $table->add('title', $this->gettext('name'));
         $table->add(null, html::tag('input', array('type' => 'text', 'name' => '_name', 'value' => $identity['name'], 'disabled' => $identities_level == 4)));
         $table->add('title', $this->gettext('email'));
         $table->add(null, html::tag('input', array('type' => 'text', 'name' => '_email', 'value' => rcube_utils::idn_to_utf8($identity['email']), 'disabled' => in_array($identities_level, array(1, 3, 4)))));
         $table->add('title', $this->gettext('organization'));
         $table->add(null, html::tag('input', array('type' => 'text', 'name' => '_organization', 'value' => $identity['organization'], 'disabled' => $identities_level == 4)));
         $table->add('title', $this->gettext('signature'));
         $table->add(null, html::tag('textarea', array('name' => '_signature', 'rows' => '3'), $identity['signature']));
         // add overlay input box to html page
         $rcmail->output->add_footer(html::tag('form', array('id' => 'newuserdialog', 'action' => $rcmail->url('plugin.newusersave'), 'method' => 'post'), html::p('hint', rcube::Q($this->gettext('identitydialoghint'))) . $table->show() . html::p(array('class' => 'formbuttons'), html::tag('input', array('type' => 'submit', 'class' => 'button mainaction', 'value' => $this->gettext('save'))))));
         $title = rcube::JQ($this->gettext('identitydialogtitle'));
         $script = "\n\$('#newuserdialog').show()\n  .dialog({modal:true, resizable:false, closeOnEscape:false, width:450, title:'{$title}'})\n  .submit(function() {\n    var i, request = {}, form = \$(this).serializeArray();\n    for (i in form)\n      request[form[i].name] = form[i].value;\n\n      rcmail.http_post('plugin.newusersave', request, true);\n      return false;\n  });\n\n\$('input[name=_name]').focus();\nrcube_webmail.prototype.new_user_dialog_close = function() { \$('#newuserdialog').dialog('close'); }\n";
         // disable keyboard events for messages list (#1486726)
         $rcmail->output->add_script($script, 'docready');
         $this->include_stylesheet('newuserdialog.css');
     }
 }
Example #11
0
 function aworkstrackpage()
 {
     $this->page();
     $this->stylesheet = "style.css";
     $this->__widgetfields[] = html::write("<script src=\"shortcuts.js\"></script><div id=\"header\"></div>");
     $this->__widgetfields[] = html::write("<h1>Seguimiento de Pedidos</h1>");
 }
Example #12
0
 /**
  * Форматирование значения. Вызывает обработчики вроде типографа.
  */
 public function format(Node $node, $em)
 {
     $value = $node->{$this->value};
     $ctx = Context::last();
     $ctx->registry->broadcast('ru.molinos.cms.format.text', array($ctx, $this->value, &$value));
     return html::wrap($em, html::cdata($value));
 }
Example #13
0
 protected function prepend()
 {
     # chargement des principales locales
     l10n::set(__DIR__ . '/locales/' . $this->okt->user->language . '/main');
     global $oktAutoloadPaths;
     #autoload
     $oktAutoloadPaths['partnersController'] = __DIR__ . '/inc/class.partners.controller.php';
     $oktAutoloadPaths['partnersRecordset'] = __DIR__ . '/inc/class.partners.recordset.php';
     #permissions
     $this->okt->addPermGroup('partners', __('m_partners_perm_group'));
     $this->okt->addPerm('partners', __('m_partners_perm_global'), 'partners');
     $this->okt->addPerm('partners_add', __('m_partners_perm_add'), 'partners');
     $this->okt->addPerm('partners_remove', __('m_partners_perm_remove'), 'partners');
     $this->okt->addPerm('partners_display', __('m_partners_perm_display'), 'partners');
     $this->okt->addPerm('partners_config', __('m_partners_perm_config'), 'partners');
     #tables
     $this->t_partners = $this->db->prefix . 'mod_partners';
     $this->t_partners_locales = $this->db->prefix . 'mod_partners_locales';
     $this->t_categories = $this->db->prefix . 'mod_partners_categories';
     $this->t_categories_locales = $this->db->prefix . 'mod_partners_categories_locales';
     #config
     $this->config = $this->okt->newConfig('conf_partners');
     $this->config->url = $this->okt->page->getBaseUrl() . $this->config->public_url[$this->okt->user->language];
     # définition des routes
     $this->okt->router->addRoute('partnersPage', new oktRoute('^(' . html::escapeHTML(implode('|', $this->config->public_url)) . ')$', 'partnersController', 'partnersPage'));
     #répertoire upload
     $this->upload_dir = OKT_UPLOAD_PATH . '/partners/';
     $this->upload_url = OKT_UPLOAD_URL . '/partners/';
     # initialisation arbre catégories
     $this->tree = new nestedTree($this->okt, $this->t_categories, 'id', 'parent_id', 'ord', array('active', 'ord'));
 }
Example #14
0
 public function createModuleMenu($method)
 {
     if (!isset($this->lang->my->{$method}->menu)) {
         return false;
     }
     $string = "<nav id='menu'><ul class='nav'>\n";
     /* Get menus of current module and current method. */
     $moduleMenus = $this->lang->my->{$method}->menu;
     $currentMethod = $this->app->getMethodName();
     /* Cycling to print every menus of current module. */
     foreach ($moduleMenus as $methodName => $methodMenu) {
         /* Split the methodMenu to label, module, method, vars. */
         list($label, $module, $method, $vars) = explode('|', $methodMenu);
         $class = '';
         if ($method == $currentMethod) {
             $class = "class='active'";
         }
         $hasPriv = commonModel::hasPriv($module, $method);
         if ($module == 'my' and $method == 'order') {
             $hasPriv = commonModel::hasPriv('order', 'browse');
         }
         if ($module == 'my' and $method == 'contract') {
             $hasPriv = commonModel::hasPriv('contract', 'browse');
         }
         if ($hasPriv) {
             $string .= "<li {$class}>" . html::a(helper::createLink($module, $method, $vars), $label) . "</li>\n";
         }
     }
     $string .= "</ul></nav>\n";
     return $string;
 }
Example #15
0
 public function delete($id)
 {
     access::verify_csrf();
     $item = model_cache::get("item", $id);
     access::required("view", $item);
     access::required("edit", $item);
     if ($item->is_album()) {
         $msg = t("Deleted album <b>%title</b>", array("title" => html::purify($item->title)));
     } else {
         $msg = t("Deleted photo <b>%title</b>", array("title" => html::purify($item->title)));
     }
     $parent = $item->parent();
     if ($item->is_album()) {
         // Album delete will trigger deletes for all children.  Do this in a batch so that we can be
         // smart about notifications, album cover updates, etc.
         batch::start();
         $item->delete();
         batch::stop();
     } else {
         $item->delete();
     }
     message::success($msg);
     $from_id = Input::instance()->get("from_id");
     if (Input::instance()->get("page_type") == "collection" && $from_id != $id) {
         json::reply(array("result" => "success", "reload" => 1));
     } else {
         json::reply(array("result" => "success", "location" => $parent->url()));
     }
 }
Example #16
0
 /**
  * show notify in msgBox.
  * 
  * @access public
  * @return string
  */
 public function notify()
 {
     $messages = $this->dao->select('COUNT(*) as count')->from(TABLE_MESSAGE)->where('`to`')->eq($this->app->user->account)->andWhere('readed')->eq(0)->fetch('count');
     if ($messages) {
         echo html::a(helper::createLink('user', 'message'), sprintf($this->lang->user->message->mine, $messages));
     }
 }
Example #17
0
 protected function prepend()
 {
     global $oktAutoloadPaths;
     # chargement des principales locales
     l10n::set(__DIR__ . '/locales/' . $this->okt->user->language . '/main');
     # autoload
     $oktAutoloadPaths['catalogController'] = __DIR__ . '/inc/class.catalog.controller.php';
     $oktAutoloadPaths['catalogFilters'] = __DIR__ . '/inc/class.catalog.filters.php';
     $oktAutoloadPaths['catalogRecordset'] = __DIR__ . '/inc/class.catalog.recordset.php';
     # permissions
     $this->okt->addPermGroup('catalog', __('m_catalog_perm_group'));
     $this->okt->addPerm('catalog', __('m_catalog_perm_global'), 'catalog');
     $this->okt->addPerm('catalog_categories', __('m_catalog_perm_categories'), 'catalog');
     $this->okt->addPerm('catalog_add', __('m_catalog_perm_add'), 'catalog');
     $this->okt->addPerm('catalog_remove', __('m_catalog_perm_remove'), 'catalog');
     $this->okt->addPerm('catalog_display', __('m_catalog_perm_display'), 'catalog');
     $this->okt->addPerm('catalog_config', __('m_catalog_perm_config'), 'catalog');
     # tables
     $this->t_products = $this->db->prefix . 'mod_catalog_products';
     $this->t_categories = $this->db->prefix . 'mod_catalog_categories';
     # config
     $this->config = $this->okt->newConfig('conf_catalog');
     $this->config->url = $this->okt->page->getBaseUrl() . $this->config->public_catalog_url;
     # définition des routes
     $this->okt->router->addRoute('catalogList', new oktRoute(html::escapeHTML($this->config->public_catalog_url), 'catalogController', 'catalogList'));
     $this->okt->router->addRoute('catalogCategory', new oktRoute('^' . html::escapeHTML($this->config->public_catalog_url) . '/(.*)$', 'catalogController', 'catalogCategory'));
     $this->okt->router->addRoute('catalogItem', new oktRoute('^' . html::escapeHTML($this->config->public_product_url) . '/(.*)$', 'catalogController', 'catalogItem'));
     # répertoire upload
     $this->upload_dir = OKT_UPLOAD_PATH . '/catalog/';
     $this->upload_url = OKT_UPLOAD_URL . '/catalog/';
     # categories
     if ($this->config->categories_enable) {
         $this->tree = new nestedTree($this->okt, $this->t_categories, 'id', 'parent_id', 'ord', array('active', 'name', 'slug', 'ord'));
     }
 }
 public static function rpc_post_subscribe(Context $ctx)
 {
     $data = $ctx->post;
     if (empty($data['sections'])) {
         throw new InvalidArgumentException("Не выбраны разделы для подписки.");
     }
     if (false === strpos($data['email'], '@')) {
         throw new InvalidArgumentException(t('Введённый email не похож на email.'));
     }
     // В массиве могут быть и другие данные, поэтому мы
     // выбираем только то, что нам нужно завернуть.
     $bulk = array('email' => $data['email'], 'sections' => $data['sections']);
     $link = new url(array('args' => array('q' => 'subscription.rpc', 'action' => 'confirm', 'code' => base64_encode(serialize($bulk)))));
     $sections = Node::findXML(array('class' => 'tag', 'deleted' => 0, 'published' => 1, 'id' => $data['sections'], '#sort' => 'name'), $ctx->db, 'section');
     if (empty($sections)) {
         throw new InvalidArgumentException("Выбраны несуществующие разделы для подписки.");
     }
     $xml = html::em('message', array('mode' => 'confirm', 'host' => MCMS_HOST_NAME, 'email' => $data['email'], 'base' => $ctx->url()->getBase($ctx), 'confirmLink' => $link->string()), html::em('sections', $sections));
     $xsl = $ctx->config->get('modules/subscription/stylesheet', os::path('lib', 'modules', 'subscription', 'message.xsl'));
     if (false === ($body = xslt::transform($xml, $xsl, null))) {
         throw new RuntimeException(t('Возникла ошибка при форматировании почтового сообщения.'));
     }
     $subject = t('Подписка на новости сайта %host', array('%host' => MCMS_HOST_NAME));
     // mcms::debug($data['email'], $subject, $body);
     BebopMimeMail::send(null, $data['email'], $subject, $body);
 }
 /**
  * 签到下班
  * @param int $uid
  */
 public function endwork($uid = NULL)
 {
     /* 构造参数 */
     $uid = $this->app->user->id;
     $time = time();
     $ip = $_SERVER["REMOTE_ADDR"];
     $where = html::IPwhere($ip);
     $haveone = $this->dao->select('begintime')->from(TABLE_CHECK)->where('id')->eq($uid)->andwhere('endtime')->eq('')->andwhere('status')->eq('1')->orderBy('pkid desc')->limit(1)->fetch();
     if ($haveone) {
         $now = time();
         $worktime_unix = $now - $haveone->begintime;
         $worktime = $worktime_unix / 3600;
         if ($worktime_unix > 54000) {
             echo "超时签出,异常。系统将把本次的下班时间置为空,当日状态设置为 未签离";
             $result = $this->dao->update(TABLE_CHECK)->set('endtime')->eq(0)->set('status')->eq('2')->where('id')->eq($uid)->andwhere('endtime')->eq('')->andwhere('status')->eq('1')->orderBy('pkid desc')->limit(1)->exec();
             $this->loadModel('action')->create('user', $uid, 'timeout_checkout');
             exit;
         } else {
             $worktime = number_format($worktime, 1);
             echo "工作时间为" . $worktime . "小时,";
             $result = $this->dao->update(TABLE_CHECK)->set('endtime')->eq($time)->set('endip')->eq($ip)->set('status')->eq('0')->where('id')->eq($uid)->andwhere('endtime')->eq('')->andwhere('status')->eq('1')->orderBy('pkid desc')->limit(1)->exec();
             if ($result == 1) {
                 echo "下班成功";
                 $this->loadModel('action')->create('user', $uid, $where . '_endwork');
             } else {
                 echo "下班失败";
                 $this->loadModel('action')->create('user', $uid, 'failed_checkout');
             }
         }
     } else {
         echo "请先上班";
         exit;
     }
 }
Example #20
0
 /**
  * loads in a string snippet of html from a file (if it can find the file) and returns that
  * if the snippet file is not found, this method returns false
  * {{placeholders}} within the snippet are replaced with values in the $replacements array if available
  * any leftover placeholders are then removed to avoid them being left in the returned html
  * 
  * the loaded snippet is saved to an internal array to avoid reading in the same file repeatedly
  * (such as for form elements where there may be many fields of the same type, for example)
  * @param string $filename the path to the snippet file
  * @param array $replacements an array of find/replace values to replace {{placeholders}} within the snippet with
  * @param bool $replace_all whether or not to replace all the {{placeholders}} within the snippet being loaded
  * @return boolean
  */
 public static function load_snippet($filename, $replacements, $replace_all = true)
 {
     $h = html::getInstance();
     if (!file_exists($filename)) {
         return false;
     }
     $contents = '';
     $find = $replace = array();
     if (isset($h->cached_snippets[$filename])) {
         $contents = $h->cached_snippets[$filename];
     } else {
         $fh = fopen($filename, 'r');
         while (!feof($fh)) {
             $contents .= fread($fh, 8192);
         }
         fclose($fh);
     }
     $h->cached_snippets[$filename] = $contents;
     // replace the sections in the template snippet with the values from the array passed in
     foreach ($replacements as $key => $value) {
         if ($value) {
             $find[] = '{{' . $key . '}}';
             $replace[] = $value;
         }
     }
     $contents = str_replace($find, $replace, $contents);
     // now get rid of any placeholders left that weren't used
     if ($replace_all) {
         $contents = preg_replace('/\\{\\{[^\\}]+\\}\\}/', '', $contents);
     }
     return $contents;
 }
Example #21
0
 /**
  * Render
  *
  * @param object $object
  * @return string
  */
 public static function render($object)
 {
     $input = $object->options['input'];
     $filter = $object->filter;
     $full_text_search = $filter['full_text_search'] ?? null;
     unset($filter['full_text_search']);
     // generating form
     $table = ['header' => ['name' => i18n(null, 'Column'), 'value' => i18n(null, 'Value'), 'sep' => '&nbsp;', 'value2' => '&nbsp;'], 'options' => []];
     // fields
     foreach ($filter as $k => $v) {
         if (!empty($v['range'])) {
             $table['options'][$k] = ['name' => ['value' => i18n(null, $v['name']) . ':', 'width' => '25%', 'class' => 'list_filter_name'], 'value' => ['value' => self::render_column($v, $k, false, $input), 'width' => '30%'], 'sep' => ['value' => '&mdash;', 'width' => '1%', 'class' => 'list_filter_value'], 'value2' => ['value' => self::render_column($v, $k, true, $input), 'width' => '30%']];
         } else {
             $table['options'][$k] = ['name' => ['value' => i18n(null, $v['name']) . ':', 'width' => '25%', 'class' => 'list_filter_name'], 'value' => ['value' => self::render_column($v, $k, false, $input), 'width' => '30%']];
         }
     }
     // full text search last
     if (!empty($full_text_search)) {
         $names = [];
         foreach ($full_text_search as $v) {
             $names[] = i18n(null, $filter[$v]['name']);
         }
         $table['options']['full_text_search'] = ['name' => ['value' => i18n(null, 'Text Search') . ':', 'class' => 'list_filter_name'], 'value' => ['value' => html::input(['name' => 'filter[full_text_search]', 'class' => 'list_filter_full_text_search', 'size' => 15, 'value' => $input['filter']['full_text_search'] ?? null])], 'value2' => ['value' => implode(', ', $names), 'class' => 'list_filter_value']];
     }
     $body = html::table($table);
     $footer = html::button2(['name' => 'submit_filter', 'value' => i18n(null, 'Submit'), 'type' => 'primary', 'onclick' => "numbers.modal.hide('list_{$object->list_link}_filter'); \$('#list_{$object->list_link}_form').attr('target', '_self'); \$('#list_{$object->list_link}_form').attr('no_ajax', ''); return true;"]);
     return html::modal(['id' => "list_{$object->list_link}_filter", 'class' => 'large', 'title' => i18n(null, 'Filter'), 'body' => $body, 'footer' => $footer]);
 }
Example #22
0
 /**
  * @see REST_Controller::_update($resource)
  */
 public function _update($photo)
 {
     access::verify_csrf();
     access::required("view", $photo);
     access::required("edit", $photo);
     $form = photo::get_edit_form($photo);
     if ($valid = $form->validate()) {
         if ($form->edit_item->filename->value != $photo->name) {
             // Make sure that there's not a conflict
             if (Database::instance()->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->where("name", $form->edit_item->filename->value)->count_records()) {
                 $form->edit_item->filename->add_error("conflict", 1);
                 $valid = false;
             }
         }
     }
     if ($valid) {
         $photo->title = $form->edit_item->title->value;
         $photo->description = $form->edit_item->description->value;
         $photo->rename($form->edit_item->filename->value);
         $photo->save();
         module::event("item_edit_form_completed", $photo, $form);
         log::success("content", "Updated photo", "<a href=\"photos/{$photo->id}\">view</a>");
         message::success(t("Saved photo %photo_title", array("photo_title" => html::purify($photo->title))));
         print json_encode(array("result" => "success"));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
 /**
  * This callback function adds a box below the message content
  * if there is a vcard attachment available
  */
 function html_output($p)
 {
     $attach_script = false;
     foreach ($this->vcard_parts as $part) {
         $vcards = rcube_vcard::import($this->message->get_part_content($part, null, true));
         // successfully parsed vcards?
         if (empty($vcards)) {
             continue;
         }
         // remove part's body
         if (in_array($part, $this->vcard_bodies)) {
             $p['content'] = '';
         }
         foreach ($vcards as $idx => $vcard) {
             // skip invalid vCards
             if (empty($vcard->email) || empty($vcard->email[0])) {
                 continue;
             }
             $display = $vcard->displayname . ' <' . $vcard->email[0] . '>';
             // add box below message body
             $p['content'] .= html::p(array('class' => 'vcardattachment'), html::a(array('href' => "#", 'onclick' => "return plugin_vcard_save_contact('" . rcube::JQ($part . ':' . $idx) . "')", 'title' => $this->gettext('addvcardmsg')), html::span(null, rcube::Q($display))));
         }
         $attach_script = true;
     }
     if ($attach_script) {
         $this->include_script('vcardattach.js');
         $this->include_stylesheet($this->local_skin_path() . '/style.css');
     }
     return $p;
 }
Example #24
0
 public function setupSlides()
 {
     $n = 0;
     $active = 'active';
     foreach ($this->items as $rec) {
         $image = $rec['image'];
         $title = $rec['title'];
         $description = $rec['description'];
         $indicators[] = html::beginTag('li', ['class' => $active, 'data-target' => "#" . $this->id, 'data-slide-to' => "{$n}"]);
         $indicators[] = html::endTag('li');
         $n = $n + 1;
         $slides[] = html::beginTag('div', ['class' => 'item item-' . $n . ' slide-image ' . $active]);
         $slides[] = html::beginTag('center');
         $slides[] = html::beginTag('img', ['class' => 'img-responsive bg-item parallax', 'src' => $image, 'data-speed' => "1"]);
         $slides[] = html::endTag('center');
         $slides[] = html::beginTag('div', ['class' => 'carousel-caption']);
         $slides[] = html::beginTag('span', ['class' => 'ban-title']);
         if ($title) {
             $slides[] = $title . '<br>' . '<hr>';
         }
         $slides[] = html::endTag('span');
         $slides[] = html::beginTag('span', ['class' => 'ban-text']);
         $slides[] = $description;
         $slides[] = html::endTag('span');
         $slides[] = html::endTag('div');
         $slides[] = html::endTag('div');
         $active = '';
     }
     $this->indicators = implode('', $indicators);
     $this->slides = implode('', $slides);
 }
Example #25
0
 static function feed($feed_id, $offset, $limit, $id)
 {
     $feed = new stdClass();
     switch ($feed_id) {
         case "latest":
             $feed->items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC")->find_all($limit, $offset);
             $all_items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC");
             $feed->max_pages = ceil($all_items->find_all()->count() / $limit);
             $feed->title = t("%site_title - Recent updates", array("site_title" => item::root()->title));
             $feed->description = t("Recent updates");
             return $feed;
         case "album":
             $item = ORM::factory("item", $id);
             access::required("view", $item);
             $feed->items = $item->viewable()->descendants($limit, $offset, array(array("type", "=", "photo")));
             $feed->max_pages = ceil($item->viewable()->descendants_count(array(array("type", "=", "photo"))) / $limit);
             if ($item->id == item::root()->id) {
                 $feed->title = html::purify($item->title);
             } else {
                 $feed->title = t("%site_title - %item_title", array("site_title" => item::root()->title, "item_title" => $item->title));
             }
             $feed->description = nl2br(html::purify($item->description));
             return $feed;
     }
 }
Example #26
0
 public function before()
 {
     // Open remote URLs in a new window
     html::$windowed_urls = TRUE;
     /**
      	* Adding admin users
     	$user = ORM::factory('user');
     	$user->email = '*****@*****.**';
     	$user->username = '******';
     	$user->password = '******';
     	$user->save();
     	// dont forget to add roles. 'login' role needs for successful login
     	//$user->add('roles', ORM::factory('role', array('name' => 'admin')));
     	$user->add('roles', ORM::factory('role', array('name' => 'login')));
     */
     parent::before();
     $this->template->scripts = array();
     $this->template->styles = array();
     $this->template->title = $this->template->content = '';
     $auth = Auth::instance();
     // set user
     $this->_user = $auth->get_user();
     $this->_admin = $this->_checkAdmin();
     $this->_supadmin = $this->_checkSupadmin();
     //echo $this->_user;
     // handle ajax
     if ($this->request->is_ajax()) {
         // ajax like call detected, don't render whole template!
         $this->_ajax = TRUE;
     } else {
         // initiates the template dynamic content (header, nav, panel, footer, ...)
         $this->init();
     }
 }
Example #27
0
 public function testShiv()
 {
     $expected = '<!--[if lt IE 9]>' . PHP_EOL;
     $expected .= '<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>' . PHP_EOL;
     $expected .= '<![endif]-->' . PHP_EOL;
     $this->assertEquals($expected, html::shiv());
 }
Example #28
0
 /**
  * Create the select code of products. 
  * 
  * @param  array     $products 
  * @param  int       $productID 
  * @param  string    $currentModule 
  * @param  string    $currentMethod 
  * @param  string    $extra 
  * @access public
  * @return string
  */
 public function select($products, $productID, $currentModule, $currentMethod, $extra = '')
 {
     $productMode = $this->cookie->productMode ? $this->cookie->productMode : 'all';
     $productGroup = array();
     $products = $this->dao->select('id, status, name')->from(TABLE_PRODUCT)->where('id')->in(array_keys($products))->orderBy('`order`')->fetchAll();
     foreach ($products as $product) {
         if ($productMode == 'noclosed' and $product->status == 'closed') {
             continue;
         }
         if ($product->status != 'closed') {
             $productGroup['&nbsp;'][$product->id] = $product->name;
         } elseif ($product->status == 'closed') {
             $productGroup[$this->lang->product->statusList['closed']][$product->id] = $product->name;
         }
     }
     /**
      * 1. if user selected by mouse, reload it. 
      * 2. if the user select by keyboard, save the event.keyCode, thus the switchProduct() can judge whether reload or not.
      * 3. if user press enter key in the select, reload it.
      * 4. if user click the go button, reload it.
      * */
     $switchCode = "switchProduct(\$('#productID').val(), '{$currentModule}', '{$currentMethod}', '{$extra}');";
     $onchange = "onchange=\"{$switchCode}\"";
     $selectHtml = html::selectGroup('productID', $productGroup, $productID, "tabindex=2 {$onchange}");
     return $selectHtml;
 }
Example #29
0
 /**
  * Embeds a github gist
  *
  * @param string $url Gist url: i.e. https://gist.github.com/2924148
  * @param string $file The name of a particular file from the gist, which should displayed only.
  * @return string
  */
 public static function gist($url, $file = null)
 {
     // url for the script file
     $url = $url . '.js' . r(!is_null($file), '?file=' . $file);
     // load the gist
     return html::tag('script', '', array('src' => $url));
 }
Example #30
0
 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $errors = array();
     try {
         $result = graphics::find_dirty_images_query()->select("id")->execute();
         $total_count = $task->get("total_count", $result->count());
         $mode = $task->get("mode", "init");
         if ($mode == "init") {
             $task->set("total_count", $total_count);
             $task->set("mode", "process");
             batch::start();
         }
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $i = 0;
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded()) {
                 try {
                     graphics::generate($item);
                     $completed++;
                     $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
                 } catch (Exception $e) {
                     $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
                     $errors[] = (string) $e;
                     $ignored[$item->id] = 1;
                 }
             }
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $total_count));
         if ($completed < $total_count) {
             $task->percent_complete = (int) (100 * ($completed + count($ignored)) / $total_count);
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($task->percent_complete == 100) {
             $task->done = true;
             $task->state = "success";
             batch::stop();
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         Kohana_Log::add("error", (string) $e);
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $errors[] = (string) $e;
     }
     if ($errors) {
         $task->log($errors);
     }
 }