public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $this->opo_view->setVar('request', $this->getRequest());
     $this->opo_view->setVar('message', $pa_settings['message'] ? $pa_settings['message'] : '<i>' . _t('No message set') . '</i>');
     return $this->opo_view->render('main_html.php');
 }
Example #2
0
 public function init()
 {
     parent::init(__FILE__);
     $this->_assetsUrl = Yii::app()->assetManager->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../assets');
     $clientScript = Yii::app()->clientScript;
     $clientScript->registerCssFile($this->_assetsUrl . '/css/widget-delivery.css');
 }
 public static function findByUsage($contextType = null, $contentSizes = array())
 {
     self::initialize();
     $widget_layouts = array();
     // get_stylsheet_directory() returns child theme path.
     $directory = get_stylesheet_directory() . "/views/widgets";
     $acf_files = self::traverseHierarchy($directory);
     $acf_files = array_merge($acf_files, self::traversePlugins());
     // Order files aphabetically.
     usort($acf_files, function ($a, $b) {
         include $a;
         $compareA = strtolower($widget_config['label']);
         include $b;
         $compareB = strtolower($widget_config['label']);
         return strcmp($compareA, $compareB);
     });
     foreach ($acf_files as $file) {
         include $file;
         // If contextType is null, or if contentType matches, add widget to list
         if (!$contextType || in_array($contextType, $widget_config["content-types"]) && (count($contentSizes) === 0 || in_array($contentSizes, $widget_config["content-sizes"]))) {
             include_once "BaseWidget.php";
             $widget_config = BaseWidget::add_extras($widget_config);
             $widget_layouts[] = $widget_config;
         }
     }
     return $widget_layouts;
 }
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $vn_threshold = time() - $pa_settings['logins_since'] * 60 * 60;
     $o_db = new Db();
     $qr_res = $o_db->query("\n\t\t\t\tSELECT e.code, e.message, e.date_time\n\t\t\t\tFROM ca_eventlog e\n\t\t\t\tWHERE\n\t\t\t\t\t(e.date_time >= ?) AND (e.code = 'LOGN')\n\t\t\t\tORDER BY\n\t\t\t\t\te.date_time DESC\n\t\t\t", $vn_threshold);
     $va_login_list = array();
     $t_user = new ca_users();
     $va_user_cache = array();
     while ($qr_res->nextRow()) {
         $va_log = $qr_res->getRow();
         $vs_message = $va_log['message'];
         $va_tmp = explode(';', $vs_message);
         $vs_username = '******';
         if (preg_match('!\'([^\']+)\'!', $va_tmp[0], $va_matches)) {
             $vs_username = $va_matches[1];
         }
         $va_log['username'] = $vs_username;
         if (!isset($va_user_cache[$vs_username])) {
             if ($t_user->load(array('user_name' => $vs_username))) {
                 $va_user_cache[$vs_username] = array('fname' => $t_user->get('fname'), 'lname' => $t_user->get('lname'), 'email' => $t_user->get('email'));
             } else {
                 $va_user_cache[$vs_username] = array('fname' => '?', 'lname' => '?', 'email' => '?');
             }
         }
         $va_log = array_merge($va_log, $va_user_cache[$vs_username]);
         $va_log['ip'] = str_replace('IP=', '', $va_tmp[1]);
         $va_login_list[] = $va_log;
     }
     $this->opo_view->setVar('request', $this->getRequest());
     $this->opo_view->setVar('login_list', $va_login_list);
     return $this->opo_view->render('main_html.php');
 }
 /**
  * @inheritDoc IComponentType::isSelectable()
  *
  * @return bool
  */
 public function isSelectable()
 {
     // Only admins get the Get Help widget.
     if (parent::isSelectable() && craft()->userSession->isAdmin()) {
         return true;
     }
     return false;
 }
Example #6
0
 /**
  * @inheritDoc IComponentType::isSelectable()
  *
  * @return bool
  */
 public function isSelectable()
 {
     // Gotta have update permission to get this widget
     if (parent::isSelectable() && craft()->userSession->checkPermission('performUpdates')) {
         return true;
     }
     return false;
 }
 public function isSelectable()
 {
     $plugin = craft()->plugins->getPlugin('analytics');
     $settings = $plugin->getSettings();
     if (empty($settings['enableRealtime'])) {
         return false;
     }
     return parent::isSelectable();
 }
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $this->opo_view->setVar('request', $this->getRequest());
     $t_watch_list = new ca_watch_list();
     $va_watched_items = $t_watch_list->getWatchedItems($this->request->user->get("user_id"));
     $this->opo_view->setVar("watched_items", $va_watched_items);
     return $this->opo_view->render('main_html.php');
 }
 /**
  *
  */
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     if ($pa_settings['feed_url']) {
         $vs_feed_url = $pa_settings['feed_url'];
     } else {
         $vs_feed_url = "http://icom.museum/rss.xml";
     }
     $vs_feed_url_md5 = md5($vs_feed_url);
     if (ExternalCache::contains($vs_feed_url_md5, 'Meow')) {
         $feed = ExternalCache::fetch($vs_feed_url_md5, 'Meow');
     } else {
         try {
             $feed = Zend_Feed::import($vs_feed_url);
         } catch (Exception $e) {
             return null;
         }
         ExternalCache::save($vs_feed_url_md5, $feed, 'Meow');
         $feed->__wakeup();
     }
     //A little style definition
     $rssViewContent = "" . "<STYLE type=\"text/css\">" . ".rssViewerWidgetContent, .rssViewerWidgetContent P, .rssViewerWidgetContent DIV, .rssViewerWidgetContent H1," . ".rssViewerWidgetContent H2" . " {margin:0px;padding:0px;margin-right:10px;padding-right:20px;}" . ".rssViewerWidgetContent H3 " . " {margin:0px;padding:0px;margin-right:10px;margin-top:10px;padding-right:20px;}" . "</STYLE>" . "<span class=\"rssViewerWidgetContent\">";
     //Initializing count to the limit : number_of_feeds
     $vn_c = 0;
     //Initializing description variable to store description with or without images
     $description = "";
     // Reading RSS feeds title, URL and description
     $this->opo_view->setVar('title', $feed->title());
     $this->opo_view->setVar('description', $feed->description());
     $this->opo_view->setVar('link', $feed->link());
     $rssViewContent .= "<h1><a href=\"" . $feed->link() . "\" target=\"_blank\">" . $feed->title() . "</a></h1>\n" . $feed->description();
     // Main loop : reading the items
     foreach ($feed as $item) {
         $vn_c++;
         if ($vn_c <= $pa_settings['number_of_feeds']) {
             // retrieve content
             $this->opo_view->setVar('item_title', $item->title());
             $this->opo_view->setVar('item_description', $item->description());
             $this->opo_view->setVar('item_link', $item->link());
             $description = $item->description();
             // when filtering images is on, remove IMG tags from description
             // when filtering HTML is on, remove all HTML tags
             if ($pa_settings['filter_html'] == 2) {
                 $description = strip_tags($description);
             } elseif ($pa_settings['filter_html'] == 1) {
                 $description = preg_replace("/<img[^>]+\\>/i", " ", $description);
             }
             // HTML generation of the content to display, 1 span surrounding each feed
             $rssViewContent .= "" . "<h3><a href=\"" . $item->link() . "\" target=\"blank\">" . $item->title() . "</a></h3>\n" . "" . $description . "\n";
         }
         $rssViewContent .= "</span>";
     }
     $this->opo_view->setVar('item_content', $rssViewContent);
     $this->opo_view->setVar('request', $this->getRequest());
     return $this->opo_view->render('main_html.php');
 }
 /**
  * @inheritDoc IWidget::getTitle()
  *
  * @return string
  */
 public function getTitle()
 {
     if ($userGroupId = $this->getSettings()->userGroupId) {
         $userGroup = craft()->userGroups->getGroupById($userGroupId);
         if ($userGroup) {
             return Craft::t('New Users') . ' – ' . Craft::t($userGroup->name);
         }
     }
     return parent::getTitle();
 }
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $this->opo_view->setVar('request', $this->getRequest());
     $this->opo_view->setVar('hours', $pa_settings['hours']);
     $vo_tq = new TaskQueue();
     $qr_completed = $this->opo_db->query("\n\t\t\t\tSELECT tq.*, u.fname, u.lname \n\t\t\t\tFROM ca_task_queue tq \n\t\t\t\tLEFT JOIN ca_users u ON u.user_id = tq.user_id \n\t\t\t\tWHERE tq.completed_on > ? \n\t\t\t\tORDER BY tq.completed_on desc\n\t\t\t", time() - 60 * 60 * $pa_settings['hours']);
     $va_completed = array();
     while ($qr_completed->nextRow()) {
         $va_row = $qr_completed->getRow();
         $va_params = caUnserializeForDatabase($va_row["parameters"]);
         $va_completed[$va_row["task_id"]]["handler_name"] = $vo_tq->getHandlerName($va_row['handler']);
         $va_completed[$va_row["task_id"]]["created"] = $va_row["created_on"];
         $va_completed[$va_row["task_id"]]["by"] = $va_row["fname"] . ' ' . $va_row['lname'];
         $va_completed[$va_row["task_id"]]["completed_on"] = $va_row["completed_on"];
         $va_completed[$va_row["task_id"]]["error_code"] = $va_row["error_code"];
         if ((int) $va_row["error_code"] > 0) {
             $o_e = new ApplicationError((int) $va_row["error_code"], '', '', '', false, false);
             $va_row["error_message"] = $o_e->getErrorMessage();
         } else {
             $va_row["error_message"] = '';
         }
         $va_completed[$va_row["task_id"]]["error_message"] = $va_row["error_message"];
         if (is_array($va_report = caUnserializeForDatabase($va_row["notes"]))) {
             $va_completed[$va_row["task_id"]]["processing_time"] = (double) $va_report['processing_time'];
         }
         $va_completed[$va_row["task_id"]]["status"] = $vo_tq->getParametersForDisplay($va_row);
     }
     $this->opo_view->setVar('jobs_done', $qr_completed->numRows());
     $this->opo_view->setVar('jobs_done_data', $va_completed);
     $qr_qd = $this->opo_db->query("\n\t\t\t\tSELECT * \n\t\t\t\tFROM ca_task_queue tq\n\t\t\t\tLEFT JOIN ca_users AS u ON tq.user_id = u.user_id\n\t\t\t\tWHERE tq.completed_on is NULL\n\t\t\t");
     $this->opo_view->setVar('jobs_queued_processing', $qr_qd->numRows());
     $va_qd_jobs = array();
     $va_pr_jobs = array();
     while ($qr_qd->nextRow()) {
         $va_row = $qr_qd->getRow();
         $va_params = caUnserializeForDatabase($va_row["parameters"]);
         if (!$vo_tq->rowKeyIsBeingProcessed($va_row["row_key"])) {
             $va_qd_jobs[$va_row["task_id"]]["handler_name"] = $vo_tq->getHandlerName($va_row['handler']);
             $va_qd_jobs[$va_row["task_id"]]["created"] = $va_row["created_on"];
             $va_qd_jobs[$va_row["task_id"]]["by"] = $va_row["fname"] . ' ' . $va_row['lname'];
             $va_qd_jobs[$va_row["task_id"]]["status"] = $vo_tq->getParametersForDisplay($va_row);
         } else {
             $va_pr_jobs[$va_row["task_id"]]["handler_name"] = $vo_tq->getHandlerName($va_row['handler']);
             $va_pr_jobs[$va_row["task_id"]]["created"] = $va_row["created_on"];
             $va_pr_jobs[$va_row["task_id"]]["by"] = $va_row["fname"] . ' ' . $va_row['lname'];
             $va_pr_jobs[$va_row["task_id"]]["status"] = $vo_tq->getParametersForDisplay($va_row);
         }
     }
     $this->opo_view->setVar('qd_job_data', $va_qd_jobs);
     $this->opo_view->setVar('pr_job_data', $va_pr_jobs);
     $this->opo_view->setVar('update_frequency', ($vn_freq = (int) $this->opo_config->get('update_frequency')) ? $vn_freq : 60);
     return $this->opo_view->render('main_html.php');
 }
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $this->opo_view->setVar('request', $this->getRequest());
     $t_set = new ca_sets();
     $va_tables = array("ca_objects", "ca_entities", "ca_places", "ca_object_lots", "ca_storage_locations", "ca_collections", "ca_occurrences");
     $va_sets = array();
     foreach ($va_tables as $vs_table) {
         $va_sets[$vs_table][] = caExtractValuesByUserLocale($t_set->getSets(array('table' => $vs_table, 'user_id' => $this->request->getUserID())));
     }
     $this->opo_view->setVar("sets_by_table", $va_sets);
     return $this->opo_view->render('main_html.php');
 }
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $this->opo_view->setVar('request', $this->getRequest());
     $va_tables = array("ca_objects", "ca_entities", "ca_places", "ca_object_lots", "ca_storage_locations", "ca_collections", "ca_occurrences");
     $va_searches = array();
     foreach ($va_tables as $vs_table) {
         $va_searches[$vs_table]["basic_search"] = $this->request->user->getSavedSearches($vs_table, "basic_search");
         $va_searches[$vs_table]["advanced_search"] = $this->request->user->getSavedSearches($vs_table, "advanced_search");
     }
     $this->opo_view->setVar("saved_searches", $va_searches);
     return $this->opo_view->render('main_html.php');
 }
Example #14
0
 /**
  *
  */
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $vs_feed_url = 'http://feeds.feedburner.com/ICanHasCheezburger';
     $vs_feed_url_md5 = md5($vs_feed_url);
     if (ExternalCache::contains($vs_feed_url_md5, 'Meow')) {
         $feed = ExternalCache::fetch($vs_feed_url_md5, 'Meow');
     } else {
         try {
             $feed = Zend_Feed::import($vs_feed_url);
         } catch (Exception $e) {
             return null;
         }
         ExternalCache::save($vs_feed_url_md5, $feed, 'Meow');
         $feed->__wakeup();
     }
     $this->opo_view->setVar('title', $feed->title());
     $vn_i = (int) rand(0, $feed->count() - 1);
     // pick a random cat
     $vn_c = 0;
     foreach ($feed as $item) {
         if ($vn_c < $vn_i) {
             $vn_c++;
             continue;
             // skip until we get to our random cat
         }
         $this->opo_view->setVar('item_title', $item->title());
         $this->opo_view->setVar('item_description', $item->description());
         $this->opo_view->setVar('item_link', $item->link());
         // Find the image URL in the encoded HTML content...
         if (preg_match("!(https://i.chzbgr.com/maxW500/[^\"']+)!i", $item->encoded(), $va_matches)) {
             $vs_url = $va_matches[1];
             $vn_width = 430;
             // force width of image to 430 pixels
             //$vn_height = floor($vn_width / 1.57);		// assume aspect ratio is 1.57 (typical). This results is an occasional squished cat but who's counting?
             $this->opo_view->setVar('item_image', "<img src='{$vs_url}' width='{$vn_width}'/>");
             break;
         }
         // if we fall through to here it means we couldn't find an image link in the encoded HTML content
         // so we just skip to the next one and see if there's a cat in there.
         $vn_c++;
     }
     $this->opo_view->setVar('request', $this->getRequest());
     return $this->opo_view->render('main_html.php');
 }
Example #15
0
	function getPath() {
		$name = $this->getName() ;
		if ($this->path) {
			return $this->path ;
		}elseif (parent::getPath()) {
			$this->path = parent::getPath() ;
			return $this->path ;
		}else{
			// If path not set explicity: calc it
			$prefix = ROOT ;
			if ($plg = $this->getPlugin()){
				$plgName = $this->getPlugin()->getSystemName();
				$prefix = PLUGIN_PATH."/".$plgName  ;
			}
			$this->path = $prefix ."/application/widgets/$name/index.php" ;
		}
		return $this->path ;
	}
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $this->opo_view->setVar('change_log', new ApplicationChangeLog());
     if ($t_table = $this->opo_datamodel->getInstanceByTableName($pa_settings['display_type'], true)) {
         $this->opo_view->setVar('table_num', $t_table->tableNum());
         $this->opo_view->setVar('table_name_plural', $t_table->getProperty('NAME_PLURAL'));
         if (($vn_threshold = (double) $pa_settings['changes_since']) <= 0) {
             $vn_threshold = 24;
         }
         if ($vn_threshold > 2160) {
             $vn_threshold = 24;
         }
         $this->opo_view->setVar('threshold_in_hours', $vn_threshold);
         $this->opo_view->setVar('request', $this->getRequest());
         return $this->opo_view->render('main_html.php');
     }
 }
 /**
  *
  */
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $t_object = new ca_objects();
     # get a random object for display
     $va_random_item = $t_object->getRandomItems(1, array('hasRepresentations' => 1));
     if (sizeof($va_random_item) > 0) {
         foreach ($va_random_item as $vn_object_id => $va_object_info) {
             $t_object->load($vn_object_id);
             $va_rep = $t_object->getPrimaryRepresentation(array('medium'));
             $this->opo_view->setVar('object_id', $vn_object_id);
             $this->opo_view->setVar('image', $va_rep["tags"]["medium"]);
             $this->opo_view->setVar('label', $t_object->getLabelForDisplay());
         }
     }
     $this->opo_view->setVar('request', $this->getRequest());
     return $this->opo_view->render('main_html.php');
 }
Example #18
0
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $va_instances = array();
     $va_tables = $this->opa_tables;
     foreach (array_keys($va_tables) as $vs_table) {
         if (!isset($pa_settings['show_' . $vs_table]) || !$pa_settings['show_' . $vs_table] || (bool) $this->getRequest()->config->get($vs_table . '_disable') && !($vs_table == 'ca_object_representations' && !(bool) $this->getRequest()->config->get('ca_objects_disable'))) {
             unset($va_tables[$vs_table]);
             continue;
         }
         require_once __CA_MODELS_DIR__ . '/' . $vs_table . '.php';
         $va_instances[$vs_table] = $t_instance = new $vs_table();
         $va_tables[$vs_table] = (int) $t_instance->getCount();
     }
     $this->opo_view->setVar('counts', $va_tables);
     $this->opo_view->setVar('instances', $va_instances);
     $this->opo_view->setVar('settings', $pa_settings);
     $this->opo_view->setVar('request', $this->getRequest());
     return $this->opo_view->render('main_html.php');
 }
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     global $g_ui_locale_id;
     if ($pa_settings["display_limit"] && intval($pa_settings["display_limit"]) > 0 && intval($pa_settings["display_limit"]) < 1000) {
         $vn_limit = intval($pa_settings["display_limit"]);
     } else {
         $vn_limit = 10;
     }
     $this->opo_view->setVar('limit', $vn_limit);
     $vn_show_type = intval($pa_settings["show_moderated_type"]);
     $vs_comment_type = "";
     switch ($vn_show_type) {
         case 1:
             $vs_mode = "moderated";
             $vs_comment_type = _t("moderated");
             break;
             # ---------------------------------------
         # ---------------------------------------
         case 0:
             $vs_mode = "unmoderated";
             $vs_comment_type = _t("unmoderated");
             break;
             # ---------------------------------------
         # ---------------------------------------
         default:
             $vs_mode = "";
             $vs_comment_type = "";
             break;
             # ---------------------------------------
     }
     $this->opo_view->setVar('comment_type', $vs_comment_type);
     $t_comments = new ca_item_comments();
     $va_comments = $t_comments->getComments($vs_mode, $vn_limit);
     $this->opo_view->setVar('comment_list', $va_comments);
     $this->opo_view->setVar('request', $this->getRequest());
     $this->opo_view->setVar('settings', $pa_settings);
     return $this->opo_view->render('main_html.php');
 }
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     $this->opo_view->setVar('request', $this->getRequest());
     $t_form = new ca_search_forms();
     if (!($vn_form_id = (int) $pa_settings["form_code"])) {
         $va_forms = caExtractValuesByUserLocale($t_form->getForms(array('table' => 'ca_objects', 'user_id' => $this->request->getUserID(), 'access' => __CA_SEARCH_FORM_READ_ACCESS__)));
         $va_tmp = array_keys($va_forms);
         $vn_form_id = array_shift($va_tmp);
     }
     $t_form->load($vn_form_id);
     $this->opo_view->setVar("t_form", $t_form);
     if ($t_form->haveAccessToForm($this->getRequest()->user->getUserID(), __CA_SEARCH_FORM_READ_ACCESS__)) {
         $vo_dm = Datamodel::load();
         $vo_result_context = new ResultContext($this->getRequest(), $vo_dm->getTableName($t_form->get("table_num")), "advanced_search");
         $va_form_data = $vo_result_context->getParameter('form_data');
         $this->opo_view->setVar("controller_name", $this->getAdvancedSearchControllerNameForTable($vo_dm->getTableName($t_form->get("table_num"))));
         $this->opo_view->setVar('form_data', $va_form_data);
         $this->opo_view->setVar('form_elements', $t_form->getHTMLFormElements($this->getRequest(), $va_form_data));
     } else {
         $t_form->clear();
     }
     return $this->opo_view->render('main_html.php');
 }
Example #21
0
 /**
  * Return Tweet button parameters suitable
  *
  * @since 1.0.0
  *
  * @return array Tweet button parameter array {
  *   @type string dashed parameter name
  *   @type string parameter value
  * }
  */
 public function toArray()
 {
     $data = parent::toArray();
     if ($this->size) {
         $data['size'] = $this->size;
     }
     // empty string is default value
     if ($this->count) {
         $data['count'] = $this->count;
     }
     // only include counturl if a count will be shown
     if ('none' !== $this->count && $this->counturl) {
         $data['counturl'] = $this->counturl;
     }
     if ($this->align) {
         $data['align'] = $this->align;
     }
     return $data;
 }
Example #22
0
 /**
  * Convert the class object into an array, removing default field values
  *
  * @since 1.0.0
  *
  * @return array properties as associative array
  */
 public function toArray()
 {
     $data = parent::toArray();
     if (false === $this->show_screen_name) {
         $data['show-screen-name'] = 'false';
     }
     if (false === $this->show_count) {
         $data['show-count'] = 'false';
     }
     if ($this->size && 'medium' !== $this->size) {
         $data['size'] = $this->size;
     }
     return $data;
 }
Example #23
0
 public static function has()
 {
     $has = ['created_at' => null, 'updated_at' => null, 'updates' => null];
     return array_merge(parent::has(), $has);
 }
Example #24
0
 public function init()
 {
     parent::init();
     $this->libUrl = Resource::getCommonUrl() . '/libs/kindeditor';
 }
Example #25
0
 /**
  *
  */
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     return $this->opo_view->render('main_html.php');
 }
Example #26
0
 public function init()
 {
     parent::init();
     $this->libUrl = Resource::getCommonUrl() . '/libs/kindeditor';
     $this->defaultParams['width'] = '"' . $this->width . '"';
 }
Example #27
0
 public function init()
 {
     parent::init();
 }
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     global $g_ui_locale_id;
     if (!in_array($pa_settings['display_type'], BaseWidget::$s_widget_settings['recentlyCreatedWidget']["display_type"]["options"])) {
         return "";
     }
     if ($t_table = $this->opo_datamodel->getInstanceByTableName($pa_settings['display_type'], true)) {
         $vo_db = new Db();
         $o_tep = new TimeExpressionParser();
         if ($pa_settings["display_limit"] && intval($pa_settings["display_limit"]) > 0 && intval($pa_settings["display_limit"]) < 1000) {
             $vn_limit = intval($pa_settings["display_limit"]);
         } else {
             $vn_limit = 11;
         }
         $vs_deleted_sql = '';
         if ($t_table->hasField('deleted')) {
             $vs_deleted_sql = " AND (t.deleted = 0) ";
         }
         $vs_idno_sql = '';
         if ($t_table->hasField('idno')) {
             $vs_idno_sql = "t.idno,";
         } elseif ($t_table->hasField('idno_stub')) {
             $vs_idno_sql = "t.idno_stub,";
         }
         $vs_sql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tt.{$t_table->primaryKey()},\n\t\t\t\t\t\tlt.{$t_table->getLabelDisplayField()},\n\t\t\t\t\t\t{$vs_idno_sql}\n\t\t\t\t\t\tlt.locale_id\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$t_table->tableName()} t\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t{$t_table->getLabelTableName()} AS lt ON t.{$t_table->primaryKey()} = lt.{$t_table->primaryKey()}\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(lt.is_preferred = 1) \n\t\t\t\t\t\t{$vs_deleted_sql}\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\tt.{$t_table->primaryKey()} DESC\n\t\t\t\t\tLIMIT\n\t\t\t\t\t\t{$vn_limit}\n\t\t\t\t";
         $qr_records = $vo_db->query($vs_sql);
         $va_item_list = array();
         while ($qr_records->nextRow() && sizeof($va_item_list) < intval($pa_settings["display_limit"])) {
             if (isset($va_item_list[$qr_records->get($t_table->primaryKey())])) {
                 // we only overwrite if we hit one with UI locale (i.e. the first hit wins if there is no label in UI locale)
                 if (!(intval($qr_records->get($t_table->getLabelTableName() . ".locale_id")) == intval($g_ui_locale_id))) {
                     continue;
                 }
             }
             $vs_sql = "\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tlog_datetime\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tca_change_log\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tlogged_table_num = " . (int) $t_table->tableNum() . "\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t\tchangetype = 'I'\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t\tlogged_row_id = " . (int) $qr_records->get($t_table->primaryKey()) . "\n\t\t\t\t\t";
             $qr_create_date = $vo_db->query($vs_sql);
             if ($qr_create_date->nextRow()) {
                 $vn_time_created = intval($qr_create_date->get("log_datetime"));
                 $o_tep->setUnixTimestamps($vn_time_created, $vn_time_created);
                 $va_options = $this->opb_dont_show_timestamp ? array('timeOmit' => true) : null;
                 $vs_datetime_text = $o_tep->getText($va_options);
             } else {
                 $vs_datetime_text = '';
             }
             $va_item_list[$qr_records->get($t_table->primaryKey())] = array("display" => $qr_records->get($t_table->getLabelTableName() . "." . $t_table->getLabelDisplayField()), "idno" => $qr_records->get("idno"), "idno_stub" => $qr_records->get("idno_stub"), "locale_id" => $qr_records->get($t_table->getLabelTableName() . ".locale_id"), "datetime" => $vs_datetime_text);
         }
         if (!(intval($pa_settings["height_px"]) > 30 && intval($pa_settings["height_px"]) < 1000)) {
             // if value is not within reasonable boundaries, set it to default
             $this->opo_view->setVar("height_px", 270);
         } else {
             $this->opo_view->setVar("height_px", intval($pa_settings["height_px"]));
         }
         $this->opo_view->setVar('item_list', $va_item_list);
         $this->opo_view->setVar('table_num', $this->opo_datamodel->getTableNum($t_table->tableName()));
         $this->opo_view->setVar('request', $this->getRequest());
         $this->opo_view->setVar('table_display', $this->opa_table_display_names[$t_table->tableName()]);
         $this->opo_view->setVar('idno_display', isset($pa_settings["display_idno"]) ? $pa_settings["display_idno"] : FALSE);
         return $this->opo_view->render('main_html.php');
     }
 }
Example #29
0
 /**
  * Return Tweet button parameters suitable
  *
  * @since 1.0.0
  *
  * @return array Tweet button parameter array {
  *   @type string dashed parameter name
  *   @type string parameter value
  * }
  */
 public function toArray()
 {
     $data = parent::toArray();
     if ($this->size) {
         $data['size'] = $this->size;
     }
     return $data;
 }
Example #30
0
 public function renderContent()
 {
     //---- HEAD ------------------------------------------------------------
     if (!empty($this->_headScripts)) {
         $this->assign('headScripts', $this->_headScripts);
     }
     if (!empty($this->_headStyles)) {
         $this->assign('headStyles', $this->_headStyles);
     }
     if (!empty($this->_headStylesheets)) {
         $this->assign('headStylesheets', $this->_headStylesheets);
     }
     $this->assign('body', $this->_body);
     //---- Bread Crumbs ----------------------------------------------------
     $maxBreadCrumbs = count($this->_breadCrumbs);
     $breadCrumbsHTML = '';
     for ($i = 0; $i < $maxBreadCrumbs; $i++) {
         $breadCrumbsHTML .= $this->_breadCrumbs[$i]->render();
         $breadCrumbsHTML .= $this->breadcrumbSeparator;
     }
     $this->assign('breadcrumbs', $breadCrumbsHTML);
     $return = parent::renderContent();
     return $return;
 }