Beispiel #1
0
 public static function register()
 {
     $atts = array('class' => 'CN_Bio_Card_Template', 'name' => 'Bio Entry Card', 'slug' => 'card-bio', 'type' => 'all', 'version' => '2.0.1', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'This is a variation of the default template which shows the bio field for an entry.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'url' => plugin_dir_url(__FILE__), 'thumbnail' => 'thumbnail.png', 'parts' => array());
     cnTemplateFactory::register($atts);
 }
 /**
  * @param array  $atts
  * @param string $content
  * @param string $tag
  *
  * @return string
  */
 public static function shortcode($atts, $content = '', $tag = 'connections')
 {
     // Grab an instance of the Connections object.
     $instance = Connections_Directory();
     $html = '';
     if (is_customize_preview()) {
         /**
          * Hook to allow the active template to be overridden and set to the current template being customized.
          *
          * @since 8.4
          *
          * @param array $atts {
          *     @type string $template The template slug of the template being customized.
          * }
          */
         $atts = apply_filters('cn_template_customizer_template', $atts);
     }
     /** @var cnTemplate $template */
     $template = cnTemplateFactory::loadTemplate($atts);
     if ($template === FALSE) {
         return cnTemplatePart::loadTemplateError($atts);
     }
     /*
      * This filter adds the current template paths to cnLocate so when template
      * part file overrides are being searched for, it'll also search in template
      * specific paths. This filter is then removed at the end of the shortcode.
      */
     add_filter('cn_locate_file_paths', array($template, 'templatePaths'));
     self::addFilterRegistry('cn_locate_file_paths');
     do_action('cn_template_include_once-' . $template->getSlug());
     do_action('cn_template_enqueue_js-' . $template->getSlug());
     /*
      * Now that the template has been loaded, Validate the user supplied shortcode atts.
      */
     $defaults = array('id' => NULL, 'slug' => NULL, 'category' => NULL, 'category_in' => NULL, 'exclude_category' => NULL, 'category_name' => NULL, 'category_slug' => NULL, 'wp_current_category' => FALSE, 'allow_public_override' => FALSE, 'private_override' => FALSE, 'show_alphaindex' => cnSettingsAPI::get('connections', 'display_results', 'index'), 'repeat_alphaindex' => cnSettingsAPI::get('connections', 'display_results', 'index_repeat'), 'show_alphahead' => cnSettingsAPI::get('connections', 'display_results', 'show_current_character'), 'list_type' => NULL, 'order_by' => NULL, 'limit' => NULL, 'offset' => NULL, 'family_name' => NULL, 'last_name' => NULL, 'title' => NULL, 'organization' => NULL, 'department' => NULL, 'district' => NULL, 'county' => NULL, 'city' => NULL, 'state' => NULL, 'zip_code' => NULL, 'country' => NULL, 'meta_query' => '', 'content' => '', 'near_addr' => NULL, 'latitude' => NULL, 'longitude' => NULL, 'radius' => 10, 'unit' => 'mi', 'template' => NULL, 'width' => NULL, 'lock' => FALSE, 'force_home' => FALSE, 'home_id' => in_the_loop() && is_page() ? get_the_ID() : cnSettingsAPI::get('connections', 'home_page', 'page_id'));
     $defaults = apply_filters('cn_list_atts_permitted', $defaults);
     $defaults = apply_filters('cn_list_atts_permitted-' . $template->getSlug(), $defaults);
     $atts = shortcode_atts($defaults, $atts, $tag);
     $atts = apply_filters('cn_list_atts', $atts);
     $atts = apply_filters('cn_list_atts-' . $template->getSlug(), $atts);
     /*
      * Convert some of the $atts values in the array to boolean.
      */
     cnFormatting::toBoolean($atts['allow_public_override']);
     cnFormatting::toBoolean($atts['private_override']);
     cnFormatting::toBoolean($atts['show_alphaindex']);
     cnFormatting::toBoolean($atts['repeat_alphaindex']);
     cnFormatting::toBoolean($atts['show_alphahead']);
     cnFormatting::toBoolean($atts['wp_current_category']);
     cnFormatting::toBoolean($atts['lock']);
     cnFormatting::toBoolean($atts['force_home']);
     // var_dump( $atts );
     /*
      * The post editor entity encodes the post text we have to decode it
      * so a match can be made when the query is run.
      */
     $atts['family_name'] = html_entity_decode($atts['family_name']);
     $atts['last_name'] = html_entity_decode($atts['last_name']);
     $atts['title'] = html_entity_decode($atts['title']);
     $atts['organization'] = html_entity_decode($atts['organization']);
     $atts['department'] = html_entity_decode($atts['department']);
     $atts['city'] = html_entity_decode($atts['city']);
     $atts['state'] = html_entity_decode($atts['state']);
     $atts['zip_code'] = html_entity_decode($atts['zip_code']);
     $atts['country'] = html_entity_decode($atts['country']);
     $atts['category_name'] = html_entity_decode($atts['category_name']);
     if (0 < strlen($atts['meta_query'])) {
         // The meta query syntax follows the JSON standard, except, the WordPress Shortcode API does not allow
         // brackets within shortcode options, so parenthesis have to be used instead, so, lets swap them
         // that was json_decode can be ran and the resulting array used in cnRetrieve::entries().
         $atts['meta_query'] = str_replace(array('(', ')'), array('[', ']'), $atts['meta_query']);
         $metaQuery = cnFormatting::maybeJSONdecode($atts['meta_query']);
         $atts['meta_query'] = is_array($metaQuery) ? $metaQuery : array();
     }
     $atts = apply_filters('cn_list_retrieve_atts', $atts);
     $atts = apply_filters('cn_list_retrieve_atts-' . $template->getSlug(), $atts);
     $results = $instance->retrieve->entries($atts);
     // $html .= print_r( $instance->lastQuery, TRUE );
     // Apply any registered filters to the results.
     if (!empty($results)) {
         $results = apply_filters('cn_list_results', $results);
         $results = apply_filters('cn_list_results-' . $template->getSlug(), $results);
         self::addFilterRegistry('cn_list_results-' . $template->getSlug());
     }
     ob_start();
     // Prints the template's CSS file.
     // NOTE: This is primarily to support legacy templates which included a CSS
     // file which was not enqueued in the page header.
     do_action('cn_template_inline_css-' . $template->getSlug(), $atts);
     // The return to top anchor
     do_action('cn_list_return_to_target', $atts);
     $html .= ob_get_clean();
     $html .= sprintf('<div class="cn-list" id="cn-list" data-connections-version="%1$s-%2$s"%3$s>', $instance->options->getVersion(), $instance->options->getDBVersion(), empty($atts['width']) ? '' : ' style="width: ' . $atts['width'] . 'px;"');
     $html .= sprintf('<div class="cn-template cn-%1$s" id="cn-%1$s" data-template-version="%2$s">', $template->getSlug(), $template->getVersion());
     // The filter should check $content that content is not empty before processing $content.
     // And if it is empty the filter should return (bool) FALSE, so the core template parts can be executed.
     $content = apply_filters("cn_shortcode_content-{$tag}", FALSE, $content, $atts, $results, $template);
     if ($content === FALSE) {
         ob_start();
         // Render the core result list header.
         cnTemplatePart::header($atts, $results, $template);
         // Render the core result list body.
         cnTemplatePart::body($atts, $results, $template);
         // Render the core result list footer.
         cnTemplatePart::footer($atts, $results, $template);
         $html .= ob_get_clean();
     } else {
         $html .= $content;
     }
     $html .= PHP_EOL . '</div>' . (WP_DEBUG ? '<!-- END #cn-' . $template->getSlug() . ' -->' : '') . PHP_EOL;
     $html .= PHP_EOL . '</div>' . (WP_DEBUG ? '<!-- END #cn-list -->' : '') . PHP_EOL;
     // Clear any filters that have been added.
     // This allows support using the shortcode multiple times on the same page.
     cnShortcode::clearFilterRegistry();
     // @todo This should be run via a filter.
     return self::removeEOL($html);
 }
 public static function register()
 {
     $atts = array('class' => 'CN_Birthday_Dark_Template', 'name' => 'Birthday Dark', 'slug' => 'birthday-dark', 'type' => 'birthday', 'version' => '2.0.1', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'Default birthday template with a black background in a table like format.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'url' => plugin_dir_url(__FILE__), 'thumbnail' => 'thumbnail.png', 'parts' => array('css' => 'styles.css'));
     cnTemplateFactory::register($atts);
 }
 public static function register()
 {
     $atts = array('class' => 'CN_Dashboard_Recently_Added_Template', 'name' => 'Dashboard: Recently Added Widget', 'slug' => 'dashboard-recent-added', 'type' => 'dashboard', 'version' => '2.0', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'Dashboard Widget that displays the recently added entries.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'url' => plugin_dir_url(__FILE__), 'thumbnail' => '', 'parts' => array('css' => 'styles.css'));
     cnTemplateFactory::register($atts);
 }
Beispiel #5
0
/**
 * Renders the Template admin page.
 *
 * @access private
 * @since  unknown
 */
function connectionsShowTemplatesPage()
{
    /*
     * Check whether user can edit Settings
     */
    if (!current_user_can('connections_manage_template')) {
        wp_die('<p id="error-page" style="-moz-background-clip:border;
				-moz-border-radius:11px;
				background:#FFFFFF none repeat scroll 0 0;
				border:1px solid #DFDFDF;
				color:#333333;
				display:block;
				font-size:12px;
				line-height:18px;
				margin:25px auto 20px;
				padding:1em 2em;
				text-align:center;
				width:700px">' . __('You do not have sufficient permissions to access this page.', 'connections') . '</p>');
    } else {
        // Grab an instance of the Connections object.
        $instance = Connections_Directory();
        $type = isset($_GET['type']) ? esc_attr($_GET['type']) : 'all';
        $templates = cnTemplateFactory::getCatalog($type);
        $adminURL = self_admin_url('admin.php');
        $pageURL = add_query_arg('page', 'connections_templates', $adminURL);
        $homeID = cnSettingsAPI::get('connections', 'connections_home_page', 'page_id');
        $homeURL = get_permalink($homeID);
        $customizerURL = add_query_arg('cn-customize-template', 'true', $homeURL);
        ?>
		<div class="wrap">

			<h1>Connections : <?php 
        _e('Templates', 'connections');
        ?>
				<a class="button add-new-h2" href="http://connections-pro.com/templates/" target="_blank"><?php 
        _e('Get More', 'connections');
        ?>
</a>
			</h1>

			<ul class="subsubsub">
				<li>
					<a <?php 
        if ('all' == $type) {
            echo 'class="current" ';
        }
        ?>
href="<?php 
        echo esc_url(add_query_arg('type', 'all', $pageURL));
        ?>
">
						<?php 
        _e('All', 'connections');
        ?>
					</a> |
				</li>
				<li>
					<a <?php 
        if ('individual' == $type) {
            echo 'class="current" ';
        }
        ?>
href="<?php 
        echo esc_url(add_query_arg('type', 'individual', $pageURL));
        ?>
">
						<?php 
        _e('Individual', 'connections');
        ?>
					</a> |
				</li>
				<li>
					<a <?php 
        if ('organization' == $type) {
            echo 'class="current" ';
        }
        ?>
href="<?php 
        echo esc_url(add_query_arg('type', 'organization', $pageURL));
        ?>
">
						<?php 
        _e('Organization', 'connections');
        ?>
					</a> |
				</li>
				<li>
					<a <?php 
        if ('family' == $type) {
            echo 'class="current" ';
        }
        ?>
href="<?php 
        echo esc_url(add_query_arg('type', 'family', $pageURL));
        ?>
">
						<?php 
        _e('Family', 'connections');
        ?>
					</a> |
				</li>
				<li>
					<a <?php 
        if ('anniversary' == $type) {
            echo 'class="current" ';
        }
        ?>
href="<?php 
        echo esc_url(add_query_arg('type', 'anniversary', $pageURL));
        ?>
">
						<?php 
        _e('Anniversary', 'connections');
        ?>
					</a> |
				</li>
				<li>
					<a <?php 
        if ('birthday' == $type) {
            echo 'class="current" ';
        }
        ?>
href="<?php 
        echo esc_url(add_query_arg('type', 'birthday', $pageURL));
        ?>
">
						<?php 
        _e('Birthday', 'connections');
        ?>
					</a>
				</li>
			</ul>

			<br class="clear">

			<table cellspacing="0" cellpadding="0" id="currenttheme">
				<tbody>
					<tr>
						<td class="current_template">
							<h2><?php 
        _e('Current Template', 'connections');
        ?>
</h2>

							<div id="current-template">
								<?php 
        $slug = $instance->options->getActiveTemplate($type);
        /** @var cnTemplate $activeTemplate */
        $activeTemplate = cnTemplateFactory::getTemplate($slug);
        if ($activeTemplate) {
            cnTemplateThumbnail($activeTemplate);
            cnTemplateAuthor($activeTemplate);
            cnTemplateDescription($activeTemplate);
            cnTemplateCustomizerButton($activeTemplate, $customizerURL, $pageURL);
            // Remove the current template so it does not show in the available templates.
            unset($templates->{$activeTemplate->getSlug()});
        } else {
            echo '<h3 class="error"> Template ', esc_attr($slug), ' can not be found.</h3>';
        }
        ?>
							</div>
							<div class="clear"></div>
						</td>

						<td class="template_instructions" colspan="2">
							<p>
								<strong><?php 
        _e('Instructions', 'connections');
        ?>
:</strong>
							</p>

							<p>
								<?php 
        _e('By default the <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/">&#91;connections&#93;</a></code> shortcode will show all entries types. To change the template used when displaying all entry types, select the "All" tab and activate the template. When the <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/list_type/">list_type</a></code>shortcode option is used to filter the entries based on the entry type, the template for that entry type will be used. To change the template used for a specific entry type, select the appropriate tab and then activate the template. If multiple entry types are specified in the <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/list_type/">list_type</a></code> shortcode option, the template for the entry type listed first will be used to display the entry list.', 'connections');
        ?>
							</p>

							<p>
								<?php 
        _e('The <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-upcoming-list/">[upcoming_list]</a></code> shortcode which displays the upcoming anniversaries and birthdays will be displayed with the template that is activated under their respective tabs.', 'connections');
        ?>
							</p>

							<p>
								<?php 
        _e('The current active template for each template type can be overridden by using the <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/template-option/">template</a></code> shortcode option.', 'connections');
        ?>
							</p>
						</td>
					</tr>
				</tbody>
			</table> <!-- /#currenttheme -->

			<table cellspacing="0" cellpadding="0" id="availablethemes">
				<tbody>
					<tr>
						<td class="current_template" colspan="3">
							<h2><?php 
        _e('Available Templates', 'connections');
        ?>
</h2>
						</td>
					</tr>

					<?php 
        $slugs = array_keys((array) $templates);
        natcasesort($slugs);
        $table = array();
        $rows = ceil(count($slugs) / 3);
        for ($row = 1; $row <= $rows; $row++) {
            for ($col = 1; $col <= 3; $col++) {
                $table[$row][$col] = array_shift($slugs);
            }
        }
        foreach ($table as $row => $cols) {
            ?>
						<tr>
							<?php 
            foreach ($cols as $col => $slug) {
                if (!isset($templates->{$slug})) {
                    continue;
                }
                /** @var cnTemplate $template */
                $template = $templates->{$slug};
                $class = array('available-theme');
                if ($row == 1) {
                    $class[] = 'top';
                }
                if ($row == $rows) {
                    $class[] = 'bottom';
                }
                if ($col == 1) {
                    $class[] = 'left';
                }
                if ($col == 3) {
                    $class[] = 'right';
                }
                ?>

								<td <?php 
                echo cnHTML::attribute('class', $class);
                ?>
>

									<?php 
                cnTemplateThumbnail($template);
                cnTemplateAuthor($template);
                cnTemplateDescription($template);
                cnTemplateDeactivateText($template);
                cnTemplateShortcodeOverride($template);
                ?>

									<span class="action-links">
										<?php 
                cntemplateActivateButton($template, $type);
                cnTemplateDeleteButton($template);
                cnTemplateCustomizerButton($template, $customizerURL, $pageURL);
                ?>
									</span>
								</td>
								<?php 
            }
            ?>
						</tr>
						<?php 
        }
        ?>
				</tbody>
			</table> <!-- /#availablethemes -->
		</div> <!-- /.wrap -->
		<?php 
    }
}
 public static function register()
 {
     $atts = array('class' => __CLASS__, 'name' => 'Profile Entry Card', 'slug' => self::SLUG, 'type' => 'all', 'version' => '3.0', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'This will show the entries in a profile format.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'url' => plugin_dir_url(__FILE__), 'thumbnail' => 'thumbnail.png', 'parts' => array(), 'supports' => array('customizer' => array('view' => array('card' => array('display' => array('title', 'org', 'dept', 'categories', 'last_updated'), 'image' => array('type', 'width', 'height', 'crop_mode', 'fallback'), 'advanced' => array('name_format')), 'single' => array('display' => array('title', 'org', 'dept', 'contact_name', 'family', 'addresses', 'phone_numbers', 'email', 'im', 'social_media', 'links', 'dates', 'bio', 'notes', 'categories', 'last_updated'), 'image' => array('type', 'width', 'height', 'crop_mode', 'fallback'), 'advanced' => array('name_format', 'contact_name_format', 'address_format', 'address_types', 'email_format', 'email_types', 'phone_format', 'phone_types', 'link_format', 'link_types', 'date_format', 'date_types')))), 'single'));
     cnTemplateFactory::register($atts);
     add_filter('cn_register_settings_fields', array(__CLASS__, 'registerSettingsDefaults'));
 }
Beispiel #7
0
function connectionsShowTemplatesPage()
{
    /*
     * Check whether user can edit Settings
     */
    if (!current_user_can('connections_manage_template')) {
        wp_die('<p id="error-page" style="-moz-background-clip:border;
				-moz-border-radius:11px;
				background:#FFFFFF none repeat scroll 0 0;
				border:1px solid #DFDFDF;
				color:#333333;
				display:block;
				font-size:12px;
				line-height:18px;
				margin:25px auto 20px;
				padding:1em 2em;
				text-align:center;
				width:700px">' . __('You do not have sufficient permissions to access this page.', 'connections') . '</p>');
    } else {
        global $connections;
        // Purge the transient so the page is freshly scanned by the template API.
        delete_transient('cn_legacy_templates');
        // cnTemplateFactory::$templates = new stdClass();
        cnTemplateFactory::registerLegacy();
        $form = new cnFormObjects();
        $type = isset($_GET['type']) ? esc_attr($_GET['type']) : 'all';
        $template = cnTemplateFactory::getCatalog($type);
        ?>
		<div class="wrap">
			<?php 
        echo get_screen_icon('connections');
        ?>

			<h2>Connections : <?php 
        _e('Templates', 'connections');
        ?>
 <a class="button add-new-h2" href="http://connections-pro.com/templates/" target="_blank"><?php 
        _e('Get More', 'connections');
        ?>
</a></h2>

			<ul class="subsubsub">
				<li><a <?php 
        if ($type === 'all') {
            echo 'class="current" ';
        }
        ?>
href="admin.php?page=connections_templates&type=all"><?php 
        _e('All', 'connections');
        ?>
</a> | </li>
				<li><a <?php 
        if ($type === 'individual') {
            echo 'class="current" ';
        }
        ?>
href="admin.php?page=connections_templates&type=individual"><?php 
        _e('Individual', 'connections');
        ?>
</a> | </li>
				<li><a <?php 
        if ($type === 'organization') {
            echo 'class="current" ';
        }
        ?>
href="admin.php?page=connections_templates&type=organization"><?php 
        _e('Organization', 'connections');
        ?>
</a> | </li>
				<li><a <?php 
        if ($type === 'family') {
            echo 'class="current" ';
        }
        ?>
href="admin.php?page=connections_templates&type=family"><?php 
        _e('Family', 'connections');
        ?>
</a> | </li>
				<li><a <?php 
        if ($type === 'anniversary') {
            echo 'class="current" ';
        }
        ?>
href="admin.php?page=connections_templates&type=anniversary"><?php 
        _e('Anniversary', 'connections');
        ?>
</a> | </li>
				<li><a <?php 
        if ($type === 'birthday') {
            echo 'class="current" ';
        }
        ?>
href="admin.php?page=connections_templates&type=birthday"><?php 
        _e('Birthday', 'connections');
        ?>
</a></li>
			</ul>

			<br class="clear">

			<table cellspacing="0" cellpadding="0" id="currenttheme">
				<tbody>
					<tr>
						<td class="current_template">
							<h2><?php 
        _e('Current Template', 'connections');
        ?>
</h2>

							<div id="current-template">
								<?php 
        $slug = $connections->options->getActiveTemplate($type);
        $activeTemplate = cnTemplateFactory::getTemplate($slug);
        // var_dump( $activeTemplate );
        if ($activeTemplate) {
            if ($activeTemplate->getThumbnail()) {
                $thumbnail = $activeTemplate->getThumbnail();
                if (!empty($thumbnail['name'])) {
                    echo '<div class="center-thumbnail"><img class="template-thumbnail" src="', $thumbnail['url'], '" /></div>';
                } else {
                    echo '<div class="center-thumbnail"><div class="template-thumbnail-none">', __('Thumbnail Not Available', 'connections'), '</div></div>';
                }
            }
            if ($activeTemplate->getAuthorURL()) {
                $author = '<a title="' . __('Visit author\'s homepage.', 'connections') . '" href="' . $activeTemplate->getAuthorURL() . '">' . $activeTemplate->getAuthor() . '</a>';
            } else {
                $author = $activeTemplate->getAuthor();
            }
            echo '<h3>', $activeTemplate->getName(), ' ', $activeTemplate->getVersion(), ' by ', $author, '</h3>';
            echo '<p class="theme-description">', $activeTemplate->getDescription(), '</p>';
            // Remove the current template so it does not show in the available templates.
            unset($template->{$activeTemplate->getSlug()});
        } else {
            echo '<h3 class="error"> Template ', esc_attr($slug), ' can not be found.</h3>';
        }
        ?>
							</div>
							<div class="clear"></div>
						</td>

						<td class="template_instructions" colspan="2">
							<p><strong><?php 
        _e('Instructions', 'connections');
        ?>
:</strong></p>
							<p>
								<?php 
        _e('By default the <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/">[connections]</a></code> shortcode will show all entries types. To change the template used when displaying all entry types, select the "All" tab and activate the template. When the <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/list_type/">list_type</a></code>shortcode option is used to filter the entries based on the entry type, the template for that entry type will be used. To change the template used for a specific entry type, select the appropriate tab and then activate the template. If multiple entry types are specified in the <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/list_type/">list_type</a></code> shortcode option, the template for the entry type listed first will be used to display the entry list.', 'connections');
        ?>
							</p>

							<p>
								<?php 
        _e('The <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-upcoming-list/">[upcoming_list]</a></code> shortcode which displays the upcoming anniversaries and birthdays will be displayed with the template that is activated under their respective tabs.', 'connections');
        ?>
							</p>

							<p>
								<?php 
        _e('The current active template for each template type can be overridden by using the <code><a href="http://connections-pro.com/documentation/connections/shortcodes/shortcode-connections/template-option/">template</a></code> shortcode option.', 'connections');
        ?>
							</p>
						</td>
					</tr>
				</tbody>
			</table>

			<table cellspacing="0" cellpadding="0" id="availablethemes">
				<tbody>
					<tr>
						<td class="current_template" colspan="3">
							<h2><?php 
        _e('Available Templates', 'connections');
        ?>
</h2>
						</td>
					</tr>

					<?php 
        $slugs = array_keys((array) $template);
        natcasesort($slugs);
        $table = array();
        $rows = ceil(count($slugs) / 3);
        for ($row = 1; $row <= $rows; $row++) {
            for ($col = 1; $col <= 3; $col++) {
                $table[$row][$col] = array_shift($slugs);
            }
        }
        foreach ($table as $row => $cols) {
            ?>
						<tr>
							<?php 
            foreach ($cols as $col => $slug) {
                $activateTokenURL = '';
                $deleteTokenURL = '';
                $class = array('available-theme');
                if ($row == 1) {
                    $class[] = 'top';
                }
                if ($row == $rows) {
                    $class[] = 'bottom';
                }
                if ($col == 1) {
                    $class[] = 'left';
                }
                if ($col == 3) {
                    $class[] = 'right';
                }
                ?>

								<td class="<?php 
                echo join(' ', $class);
                ?>
">

									<?php 
                if (!isset($template->{$slug})) {
                    continue;
                }
                // var_dump( $template->{ $slug } );
                if ($template->{$slug}->getThumbnail()) {
                    $thumbnail = $template->{$slug}->getThumbnail();
                    if (!empty($thumbnail['name'])) {
                        echo '<div class="center-thumbnail"><img class="template-thumbnail" src="', $thumbnail['url'], '" width="300" height="225"></div>';
                    } else {
                        echo '<div class="center-thumbnail"><div class="template-thumbnail-none" style="width: 300px; height: 225px"><p>', __('Thumbnail Not Available', 'connections'), '</p></div></div>';
                    }
                }
                if ($template->{$slug}->getAuthorURL()) {
                    $author = '<a title="Visit author\'s homepage." href="' . $template->{$slug}->getAuthorURL() . '">' . $template->{$slug}->getAuthor() . '</a>';
                } else {
                    $author = $template->{$slug}->getAuthor();
                }
                echo '<h3>', $template->{$slug}->getName(), ' ', $template->{$slug}->getVersion(), ' by ', $author, '</h3>';
                echo '<p class="description">', $template->{$slug}->getDescription(), '</p>';
                echo '<p>', __('Shortcode Override:', 'connections'), '<code> template="', $slug, '"</code></p>';
                ?>

									<span class="action-links">
										<?php 
                $activateTokenURL = $form->tokenURL('admin.php?cn-action=activate_template&type=' . $type . '&template=' . $template->{$slug}->getSlug(), 'activate_' . $template->{$slug}->getSlug());
                if ($template->{$slug}->isCustom() === TRUE && $template->{$slug}->isLegacy() === TRUE) {
                    $deleteTokenURL = $form->tokenURL('admin.php?cn-action=delete_template&type=' . $type . '&template=' . $template->{$slug}->getSlug(), 'delete_' . $template->{$slug}->getSlug());
                }
                ?>

										<a class="button-primary" href="<?php 
                echo esc_attr($activateTokenURL);
                ?>
" title="Activate '<?php 
                echo esc_attr($template->{$slug}->getName());
                ?>
'"><?php 
                _e('Activate', 'connections');
                ?>
</a>

										<?php 
                if (!empty($deleteTokenURL)) {
                    ?>
											 | <a class="button button-warning" href="<?php 
                    echo esc_attr($deleteTokenURL);
                    ?>
" title="Delete '<?php 
                    echo esc_attr($template->{$slug}->getName());
                    ?>
'" onclick="return confirm('You are about to delete this theme \'<?php 
                    echo esc_attr($template->{$slug}->getName());
                    ?>
\'\n  \'Cancel\' to stop, \'OK\' to delete.');">Delete</a>
										<?php 
                }
                ?>
									</span>
							<?php 
                if ($template->{$slug}->isCustom() === FALSE) {
                    echo '<p class="description">', __('This a core template and can not be deleted.', 'connections'), '</p>';
                } else {
                    if ($template->{$slug}->isCustom() === TRUE && $template->{$slug}->isLegacy() === FALSE) {
                        echo '<p class="description">', __('This template is a plugin. You can deactivate and delete the template from the Plugins admin page.', 'connections'), '</p>';
                    }
                }
            }
            ?>
								</td>
						</tr>
					<?php 
        }
        ?>


				</tbody>
			</table>

			<?php 
        if (file_exists(CN_CUSTOM_TEMPLATE_PATH) && is_writeable(CN_CUSTOM_TEMPLATE_PATH)) {
            ?>

			<table cellspacing="0" cellpadding="0" id="installthemes">
				<tbody>
					<tr>
						<td class="install_template" colspan="3">
							<h2><?php 
            _e('Install Legacy Template', 'connections');
            ?>
</h2>

							<p><?php 
            printf(__("If you puchased your template after 3.25.2013, please follow these <a href='%s'>installation instructions</a>. If you are upgrading your template purchased prior to 3.25.2013, please take note of the special upgrade instructions found on the same page.", 'connections'), 'http://connections-pro.com/documentation/plugin/install/templates/');
            ?>
</p>

							<?php 
            $formAttr = array('action' => '', 'method' => 'post', 'enctype' => 'multipart/form-data');
            $form->open($formAttr);
            $form->tokenField('install_template');
            ?>

							<p>
								<input type="hidden" name="cn-action" value="install_template"/>

								<label for='template'><?php 
            _e('Select Template:', 'connections');
            ?>
									<input type='file' value='' name='template' size='25' />
								</label>
								<input type="submit" value="<?php 
            _e('Install Now', 'connections');
            ?>
" class="button">
							</p>

							<?php 
            $form->close();
            ?>
						</td>
					</tr>
				</tbody>
			</table>

			<?php 
        }
        ?>

		</div>
	<?php 
    }
}
 public static function register()
 {
     $atts = array('class' => 'CN_Single_Card_Template', 'name' => 'Single Entry Card', 'slug' => 'card-single', 'type' => 'individual', 'version' => '2.0.1', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'This is a variation of the default template does not show the return to top anchor.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'url' => plugin_dir_url(__FILE__), 'thumbnail' => 'thumbnail.png', 'parts' => array());
     cnTemplateFactory::register($atts);
 }
Beispiel #9
0
 public static function register()
 {
     $atts = array('class' => 'CN_Profile_Template', 'name' => 'Profile Entry Card', 'slug' => 'profile', 'type' => 'all', 'version' => '2.0.1', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'This will show the entries in a profile format.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'url' => plugin_dir_url(__FILE__), 'thumbnail' => 'thumbnail.png', 'parts' => array());
     cnTemplateFactory::register($atts);
 }
/**
 * Display the upcoming list.
 *
 * @access public
 * @since  unknown
 *
 * @param array  $atts
 * @param string $content [optional]
 * @param string $tag     [optional] When called as the callback for add_shortcode, the shortcode tag is passed
 *                        automatically. Manually setting the shortcode tag so the function can be called
 *                        independently.
 *
 * @return string
 */
function _upcoming_list($atts, $content = NULL, $tag = 'upcoming_list')
{
    global $connections, $wpdb;
    // $template =& $connections->template;
    $out = '';
    $alternate = '';
    $atts = shortcode_atts(array('list_type' => 'birthday', 'days' => '30', 'include_today' => TRUE, 'private_override' => FALSE, 'date_format' => 'F jS', 'show_lastname' => FALSE, 'show_title' => TRUE, 'list_title' => NULL, 'template' => NULL), $atts, $tag);
    /*
     * Convert some of the $atts values in the array to boolean.
     */
    cnFormatting::toBoolean($atts['include_today']);
    cnFormatting::toBoolean($atts['private_override']);
    cnFormatting::toBoolean($atts['show_lastname']);
    cnFormatting::toBoolean($atts['repeat_alphaindex']);
    cnFormatting::toBoolean($atts['show_title']);
    /*
     * If a list type was specified in the shortcode, load the template based on that type.
     * However, if a specific template was specified, that should preempt the template to be loaded based on the list type if it was specified..
     */
    if (!empty($atts['template'])) {
        $template = cnTemplateFactory::getTemplate($atts['template']);
    } else {
        $templateSlug = $connections->options->getActiveTemplate($atts['list_type']);
        $template = cnTemplateFactory::getTemplate($templateSlug);
    }
    // No template found return error message.
    if ($template == FALSE) {
        return '<p style="color:red; font-weight:bold; text-align:center;">' . sprintf(__('ERROR: Template %1$s not found.', 'connections'), $atts['template']) . '</p>';
    }
    do_action('cn_template_include_once-' . $template->getSlug());
    do_action('cn_template_enqueue_js-' . $template->getSlug());
    /*
     * Set the query vars and run query.
     */
    // Show only public or private [if permitted] entries.
    if (is_user_logged_in() || $atts['private_override'] != FALSE) {
        $visibilityfilter = " AND (visibility='private' OR visibility='public') AND (" . $atts['list_type'] . " != '')";
    } else {
        $visibilityfilter = " AND (visibility='public') AND (`" . $atts['list_type'] . "` != '')";
    }
    // Get the current date from WP which should have the current time zone offset.
    $wpCurrentDate = date('Y-m-d', $connections->options->wpCurrentTime);
    // Whether or not to include the event occurring today or not.
    $atts['include_today'] ? $includeToday = '<=' : ($includeToday = '<');
    $newSQL = "SELECT * FROM " . CN_ENTRY_TABLE . " WHERE" . "  (YEAR(DATE_ADD('{$wpCurrentDate}', INTERVAL " . $atts['days'] . " DAY))" . " - YEAR(DATE_ADD(FROM_UNIXTIME(`" . $atts['list_type'] . "`), INTERVAL " . $connections->options->sqlTimeOffset . " SECOND)) )" . " - ( MID(DATE_ADD('{$wpCurrentDate}', INTERVAL " . $atts['days'] . " DAY),5,6)" . " < MID(DATE_ADD(FROM_UNIXTIME(`" . $atts['list_type'] . "`), INTERVAL " . $connections->options->sqlTimeOffset . " SECOND),5,6) )" . " > ( YEAR('{$wpCurrentDate}')" . " - YEAR(DATE_ADD(FROM_UNIXTIME(`" . $atts['list_type'] . "`), INTERVAL " . $connections->options->sqlTimeOffset . " SECOND)) )" . " - ( MID('{$wpCurrentDate}',5,6)" . " " . $includeToday . " MID(DATE_ADD(FROM_UNIXTIME(`" . $atts['list_type'] . "`), INTERVAL " . $connections->options->sqlTimeOffset . " SECOND),5,6) )" . $visibilityfilter;
    //$out .= print_r($newSQL , TRUE);
    $results = $wpdb->get_results($newSQL);
    //$out .= print_r($results , TRUE);
    // If there are no results no need to proceed and output message.
    if (empty($results)) {
        $noResultMessage = __('No results.', 'connections');
        $noResultMessage = apply_filters('cn_upcoming_no_result_message', $noResultMessage);
        $out .= '<p class="cn-upcoming-no-results">' . $noResultMessage . '</p>';
    } else {
        /*The SQL returns an array sorted by the birthday and/or anniversary date. However the year end wrap needs to be accounted for.
        		Otherwise earlier months of the year show before the later months in the year. Example Jan before Dec. The desired output is to show
        		Dec then Jan dates.  This function checks to see if the month is a month earlier than the current month. If it is the year is changed to the following year rather than the current.
        		After a new list is built, it is resorted based on the date.*/
        foreach ($results as $key => $row) {
            if (gmmktime(23, 59, 59, gmdate('m', $row->{$atts}['list_type']), gmdate('d', $row->{$atts}['list_type']), gmdate('Y', $connections->options->wpCurrentTime)) < $connections->options->wpCurrentTime) {
                $dateSort[] = $row->{$atts}['list_type'] = gmmktime(0, 0, 0, gmdate('m', $row->{$atts}['list_type']), gmdate('d', $row->{$atts}['list_type']), gmdate('Y', $connections->options->wpCurrentTime) + 1);
            } else {
                $dateSort[] = $row->{$atts}['list_type'] = gmmktime(0, 0, 0, gmdate('m', $row->{$atts}['list_type']), gmdate('d', $row->{$atts}['list_type']), gmdate('Y', $connections->options->wpCurrentTime));
            }
        }
        array_multisort($dateSort, SORT_ASC, $results);
        if (empty($atts['list_title'])) {
            switch ($atts['list_type']) {
                case 'birthday':
                    if ($atts['days'] >= 1) {
                        $list_title = 'Upcoming Birthdays the next ' . $atts['days'] . ' days';
                    } else {
                        $list_title = 'Today\'s Birthdays';
                    }
                    break;
                case 'anniversary':
                    if ($atts['days'] >= 1) {
                        $list_title = 'Upcoming Anniversaries the next ' . $atts['days'] . ' days';
                    } else {
                        $list_title = 'Today\'s Anniversaries';
                    }
                    break;
            }
        } else {
            $list_title = $atts['list_title'];
        }
        ob_start();
        // Prints the template's CSS file.
        do_action('cn_template_inline_css-' . $template->getSlug(), $atts);
        $out .= ob_get_contents();
        ob_end_clean();
        $out .= '<div class="connections-list cn-upcoming cn-' . $atts['list_type'] . '" id="cn-list" data-connections-version="' . $connections->options->getVersion() . '-' . $connections->options->getDBVersion() . '">' . "\n";
        $out .= "\n" . '<div class="cn-template cn-' . $template->getSlug() . '" id="cn-' . $template->getSlug() . '">' . "\n";
        $out .= "\n" . '<div class="cn-clear" id="cn-list-head">' . "\n";
        if ($atts['show_title']) {
            $out .= '<div class="cn-upcoming-title">' . $list_title . '</div>';
        }
        $out .= "\n" . '</div>' . "\n";
        $out .= '<div class="cn-clear" id="cn-list-body">' . "\n";
        foreach ($results as $row) {
            $entry = new cnvCard($row);
            $vCard =& $entry;
            $entry->name = '';
            $alternate == '' ? $alternate = '-alternate' : ($alternate = '');
            /*
             * Whether or not to show the last name.
             * Setting $entry->name is for compatibility to versions prior to 0.7.1.6
             */
            !$atts['show_lastname'] ? $entry->name = $entry->getFirstName() : ($entry->name = $entry->getFullFirstLastName());
            if (!$atts['show_lastname']) {
                $entry->setLastName('');
            }
            $out .= '<div class="cn-upcoming-row' . $alternate . ' vcard ' . '">' . "\n";
            ob_start();
            do_action('cn_action_card-' . $template->getSlug(), $entry, $template, $atts);
            $out .= ob_get_contents();
            ob_end_clean();
            $out .= '</div>' . "\n";
        }
        $out .= "\n" . '</div>' . "\n";
        $out .= "\n" . '<div class="cn-clear" id="cn-list-foot">' . "\n";
        $out .= "\n" . '</div>' . "\n";
        $out .= "\n" . '</div>' . "\n";
        $out .= "\n" . '</div>' . "\n";
    }
    if (cnSettingsAPI::get('connections', 'connections_compatibility', 'strip_rnt')) {
        $search = array("\r\n", "\r", "\n", "\t");
        $replace = array('', '', '', '');
        $out = str_replace($search, $replace, $out);
    }
    return $out;
}
 public static function register()
 {
     $atts = array('class' => 'CN_Card_Table_Format_Template', 'name' => 'Table Entry Card', 'slug' => 'card-tableformat', 'type' => 'all', 'version' => '2.0.1', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'This is a variation of the default template which is formatted using a table. This template is recommended when compatibility with Internet Explorer 6 is required.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'url' => plugin_dir_url(__FILE__), 'thumbnail' => 'thumbnail.png', 'parts' => array());
     cnTemplateFactory::register($atts);
 }
Beispiel #12
0
 public static function register()
 {
     $atts = array('class' => 'CN_Names_Template', 'name' => 'Names', 'slug' => 'names', 'type' => 'all', 'version' => '1.0.1', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'A simple responsive template which outputs a list of every name within the directory in a column format if the browser supports it. This template is not recommended for very large directories.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'parts' => array('css' => 'style.css'));
     cnTemplateFactory::register($atts);
 }
 /**
  * Builds a catalog of all the available Legacy templates from the supplied and the custom template directories.
  *
  * @access private
  * @since 0.7.6
  * @return void
  */
 private static function scan()
 {
     /**
      * --> START <-- Find the available templates
      */
     $templatePaths = array(CN_TEMPLATE_PATH, CN_CUSTOM_TEMPLATE_PATH);
     $templates = new stdClass();
     $baseDirs = array();
     if (0 < strlen(ini_get('open_basedir'))) {
         $baseDirs = explode(PATH_SEPARATOR, ini_get('open_basedir'));
         foreach ($baseDirs as $key => $path) {
             $baseDirs[$key] = wp_normalize_path($path);
         }
     }
     foreach ($templatePaths as $templatePath) {
         $templatePath = wp_normalize_path($templatePath);
         foreach ($baseDirs as $path) {
             if (FALSE === stripos($templatePath, $path)) {
                 continue;
             }
         }
         if (!is_dir($templatePath) && !is_readable($templatePath)) {
             continue;
         }
         if (!($templateDirectories = @opendir($templatePath))) {
             continue;
         }
         // var_dump($templatePath);
         //$templateDirectories = opendir($templatePath);
         while (($templateDirectory = readdir($templateDirectories)) !== FALSE) {
             $path = trailingslashit($templatePath . $templateDirectory);
             if (@is_dir($path) && @is_readable($path)) {
                 if (file_exists($path . 'meta.php') && file_exists($path . 'template.php')) {
                     $template = new stdClass();
                     include $path . 'meta.php';
                     $template->slug = $templateDirectory;
                     if (!isset($template->type)) {
                         $template->type = 'all';
                     }
                     // PHP 5.4 warning fix.
                     if (!isset($templates->{$template->type})) {
                         $templates->{$template->type} = new stdClass();
                     }
                     if (!isset($templates->{$template->type}->{$template->slug})) {
                         $templates->{$template->type}->{$template->slug} = new stdClass();
                     }
                     // Load the template metadate from the meta.php file
                     $templates->{$template->type}->{$template->slug}->name = $template->name;
                     $templates->{$template->type}->{$template->slug}->version = $template->version;
                     $templates->{$template->type}->{$template->slug}->uri = isset($template->uri) ? 'http://' . $template->uri : '';
                     $templates->{$template->type}->{$template->slug}->author = $template->author;
                     $templates->{$template->type}->{$template->slug}->description = isset($template->description) ? $template->description : '';
                     $templates->{$template->type}->{$template->slug}->path = $path;
                     $templates->{$template->type}->{$template->slug}->slug = $template->slug;
                     $templates->{$template->type}->{$template->slug}->custom = CN_CUSTOM_TEMPLATE_PATH === $templatePath ? TRUE : FALSE;
                     if (file_exists($path . 'styles.css')) {
                         $templates->{$template->type}->{$template->slug}->cssPath = TRUE;
                     }
                     if (file_exists($path . 'template.js')) {
                         $templates->{$template->type}->{$template->slug}->jsPath = TRUE;
                     }
                     if (file_exists($path . 'functions.php')) {
                         $templates->{$template->type}->{$template->slug}->phpPath = TRUE;
                     }
                     if (file_exists($path . 'thumbnail.png')) {
                         $templates->{$template->type}->{$template->slug}->thumbnailURL = TRUE;
                     }
                 }
             }
         }
         //var_dump($templateDirectories);
         @closedir($templateDirectories);
     }
     /**
      * --> END <-- Find the available templates
      */
     self::$legacy = $templates;
 }
 public static function register()
 {
     $atts = array('class' => 'CN_Dashboard_Upcoming_Template', 'name' => 'Dashboard: Upcoming Widget', 'slug' => 'dashboard-upcoming', 'type' => 'dashboard', 'version' => '2.0', 'author' => 'Steven A. Zahm', 'authorURL' => 'connections-pro.com', 'description' => 'Dashboard Widget that displays Upcoming Anniversies and Birthdays.', 'custom' => FALSE, 'path' => plugin_dir_path(__FILE__), 'url' => plugin_dir_url(__FILE__), 'thumbnail' => '', 'parts' => array('css' => 'styles.css'));
     cnTemplateFactory::register($atts);
 }