forked from joomla/Component-Builder
Completed the get snippets area so JCB community snippets can with easy be added to the local snippets gh-92.
This commit is contained in:
parent
f34e1b19f8
commit
268b609cea
@ -111,11 +111,11 @@ Component Builder is mapped as a component in itself on my local development env
|
||||
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
||||
+ *Name*: [Component Builder](http://vdm.bz/component-builder)
|
||||
+ *First Build*: 30th April, 2015
|
||||
+ *Last Build*: 16th November, 2017
|
||||
+ *Last Build*: 17th November, 2017
|
||||
+ *Version*: 2.6.4
|
||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
+ *Line count*: **167476**
|
||||
+ *Line count*: **167866**
|
||||
+ *File count*: **1070**
|
||||
+ *Folder count*: **176**
|
||||
|
||||
|
@ -111,11 +111,11 @@ Component Builder is mapped as a component in itself on my local development env
|
||||
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
||||
+ *Name*: [Component Builder](http://vdm.bz/component-builder)
|
||||
+ *First Build*: 30th April, 2015
|
||||
+ *Last Build*: 16th November, 2017
|
||||
+ *Last Build*: 17th November, 2017
|
||||
+ *Version*: 2.6.4
|
||||
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
|
||||
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
+ *Line count*: **167476**
|
||||
+ *Line count*: **167866**
|
||||
+ *File count*: **1070**
|
||||
+ *Folder count*: **176**
|
||||
|
||||
|
@ -60,6 +60,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy
|
||||
$this->registerTask('checkFunctionName', 'ajax');
|
||||
$this->registerTask('usedin', 'ajax');
|
||||
$this->registerTask('snippetDetails', 'ajax');
|
||||
$this->registerTask('setSnippetGithub', 'ajax');
|
||||
$this->registerTask('fieldOptions', 'ajax');
|
||||
}
|
||||
|
||||
@ -768,6 +769,45 @@ class ComponentbuilderControllerAjax extends JControllerLegacy
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'setSnippetGithub':
|
||||
try
|
||||
{
|
||||
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
|
||||
$pathValue = $jinput->get('path', NULL, 'STRING');
|
||||
$statusValue = $jinput->get('status', NULL, 'WORD');
|
||||
if($pathValue && $statusValue && $user->id != 0)
|
||||
{
|
||||
$result = $this->getModel('ajax')->setSnippetGithub($pathValue, $statusValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
if($callback = $jinput->get('callback', null, 'CMD'))
|
||||
{
|
||||
echo $callback . "(".json_encode($result).");";
|
||||
}
|
||||
elseif($returnRaw)
|
||||
{
|
||||
echo json_encode($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($result).");";
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if($callback = $jinput->get('callback', null, 'CMD'))
|
||||
{
|
||||
echo $callback."(".json_encode($e).");";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($e).");";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'fieldOptions':
|
||||
try
|
||||
{
|
||||
|
@ -866,7 +866,15 @@ COM_COMPONENTBUILDER_ALWAYS_INSURE_THAT_YOU_HAVE_YOUR_LOCAL_COMPONENTS_BACKED_UP
|
||||
COM_COMPONENTBUILDER_ANY_SELECTION_ONLY_FOUR_LISTRADIOCHECKBOXESDYNAMIC_LIST="Any Selection (only 4 list/radio/checkboxes/dynamic_list)"
|
||||
COM_COMPONENTBUILDER_AN_ERROR_HAS_OCCURRED="An error has occurred"
|
||||
COM_COMPONENTBUILDER_ARCHIVED="Archived"
|
||||
COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_ADD_THIS_NEW_JCB_COMMUNITY_SNIPPET_TO_YOUR_LOCAL_SNIPPETS="Are you sure you would like to add this new JCB community snippet to your local snippets?"
|
||||
COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_CONTINUE="Are you sure you would like to continue?"
|
||||
COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_REPLACE_YOUR_LOCAL_SNIPPET_WITH_THIS_JCB_COMMUNITY_SNIPPET="Are you sure you would like to replace your local snippet with this JCB community snippet?"
|
||||
COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_NEWER_JCB_COMMUNITY_SNIPPET="Are you sure you would like to update your local snippet with this newer JCB community snippet?"
|
||||
COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_OLDER_JCB_COMMUNITY_SNIPPET="Are you sure you would like to update your local snippet with this older JCB community snippet?"
|
||||
COM_COMPONENTBUILDER_AUTHOR="Author"
|
||||
COM_COMPONENTBUILDER_AUTHOR_EMAIL="Author Email"
|
||||
COM_COMPONENTBUILDER_AUTHOR_NAME="Author Name"
|
||||
COM_COMPONENTBUILDER_AUTHOR_WEBSITE="Author Website"
|
||||
COM_COMPONENTBUILDER_AUTO_CHECKIN="Auto Check-in"
|
||||
COM_COMPONENTBUILDER_A_FEW_CLOSED_ISSUES_FROM_GITHUB_IS_LOADING="A few closed issues from Github is loading"
|
||||
COM_COMPONENTBUILDER_A_FEW_OPEN_ISSUES_FROM_GITHUB_IS_LOADING="A few open issues from Github is loading"
|
||||
@ -893,6 +901,7 @@ COM_COMPONENTBUILDER_CHAIN="Chain"
|
||||
COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="Check your owner details, it has not been set. Open the JCB Global Options, go to the Company tab and add the correct company details there."
|
||||
COM_COMPONENTBUILDER_CLEAR_TMP="Clear tmp"
|
||||
COM_COMPONENTBUILDER_COMPANY="Company"
|
||||
COM_COMPONENTBUILDER_COMPANY_NAME="Company Name"
|
||||
COM_COMPONENTBUILDER_COMPANY_S="Company: %s"
|
||||
COM_COMPONENTBUILDER_COMPILER="Compiler"
|
||||
COM_COMPONENTBUILDER_COMPILER_ACCESS="Compiler Access"
|
||||
@ -3033,6 +3042,7 @@ COM_COMPONENTBUILDER_DASHBOARD_TEMPLATE_ADD="Add Template<br /><br />"
|
||||
COM_COMPONENTBUILDER_DATE="Date"
|
||||
COM_COMPONENTBUILDER_DEBUG_LINE_NUMBERS="Debug (line numbers)"
|
||||
COM_COMPONENTBUILDER_DEFAULT_VIEW="Default View"
|
||||
COM_COMPONENTBUILDER_DESCRIPTION="Description"
|
||||
COM_COMPONENTBUILDER_DETAILS="Details"
|
||||
COM_COMPONENTBUILDER_DIVERGED="Diverged"
|
||||
COM_COMPONENTBUILDER_DOES_THIS_PACKAGE_REQUIRE_A_KEY_TO_INSTALL="Does this package require a key to install"
|
||||
@ -3361,6 +3371,10 @@ COM_COMPONENTBUILDER_EMEMAILEM_BSB="<em>Email:</em> <b>%s</b>"
|
||||
COM_COMPONENTBUILDER_EMLICENSEEM_BSB="<em>License:</em> <b>%s</b>"
|
||||
COM_COMPONENTBUILDER_EMOWNEREM_BSB="<em>Owner:</em> <b>%s</b>"
|
||||
COM_COMPONENTBUILDER_EMWEBSITEEM_BSB="<em>Website:</em> <b>%s</b>"
|
||||
COM_COMPONENTBUILDER_ERROR_THE_PATH_HAS_A_MISMATCH_AND_COULD_THEREFORE_NOT_RETRIEVE_THE_SNIPPET_FROM_GITHUB="Error! The path has a mismatch and could therefore not retrieve the snippet from gitHub!"
|
||||
COM_COMPONENTBUILDER_ERROR_THE_SNIPPET_IS_FAULTY_AND_COULD_NOT_BE_SAVED="Error! The snippet is faulty and could not be saved."
|
||||
COM_COMPONENTBUILDER_ERROR_YOU_DO_NOT_HAVE_ACCESS_TO_THE_SNIPPETS="Error! You do not have access to the snippets."
|
||||
COM_COMPONENTBUILDER_ERROR_YOU_DO_NOT_HAVE_PERMISSION_TO_CREATE_THE_SNIPPET="Error! You do not have permission to create the snippet."
|
||||
COM_COMPONENTBUILDER_EXACT_LENGTH_ONLY_FOUR_TEXT_FIELD="Exact Length (only 4 text_field)"
|
||||
COM_COMPONENTBUILDER_EXPORTIMPORT_DATA="Export/Import Data"
|
||||
COM_COMPONENTBUILDER_EXPORT_COMPLETED="Export Completed!"
|
||||
@ -3761,6 +3775,7 @@ COM_COMPONENTBUILDER_FTP_STATUS="Status"
|
||||
COM_COMPONENTBUILDER_FTP_VERSION_DESC="A count of the number of times this FTP has been revised."
|
||||
COM_COMPONENTBUILDER_FTP_VERSION_LABEL="Revision"
|
||||
COM_COMPONENTBUILDER_FULL_WIDTH_IN_TAB="Full Width in Tab"
|
||||
COM_COMPONENTBUILDER_GET_SNIPPET="Get snippet"
|
||||
COM_COMPONENTBUILDER_GET_SNIPPETS="Get Snippets"
|
||||
COM_COMPONENTBUILDER_GET_SNIPPETS_ACCESS="Get Snippets Access"
|
||||
COM_COMPONENTBUILDER_GET_SNIPPETS_ACCESS_DESC=" Allows the users in this group to access get snippets."
|
||||
@ -3768,6 +3783,8 @@ COM_COMPONENTBUILDER_GET_SNIPPETS_DESC="The compiler"
|
||||
COM_COMPONENTBUILDER_GET_SNIPPETS_SNIPPETS_BUTTON_ACCESS="Get Snippets Snippets Button Access"
|
||||
COM_COMPONENTBUILDER_GET_SNIPPETS_SNIPPETS_BUTTON_ACCESS_DESC=" Allows the users in this group to access the snippets button."
|
||||
COM_COMPONENTBUILDER_GET_THE_KEY_FROM_BSB_FOR_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA="Get the key from <b>%s</b> for <a class="btn btn-primary" href="%s" target="_blank" title="get a key from %s">%s</a>"
|
||||
COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY="Get the snippet from gitHub and install it locally"
|
||||
COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION="Get the snippet from gitHub and update the local version"
|
||||
COM_COMPONENTBUILDER_GLOBAL="Global"
|
||||
COM_COMPONENTBUILDER_GREAT_THIS_FUNCTION_NAME_WILL_WORK="Great, this function name will work!"
|
||||
COM_COMPONENTBUILDER_HAS_METADATA="Has Metadata"
|
||||
@ -3945,6 +3962,7 @@ COM_COMPONENTBUILDER_ISOLATE="Isolate"
|
||||
COM_COMPONENTBUILDER_ISSUE="issue"
|
||||
COM_COMPONENTBUILDER_IS_NOT_ONLY_FOUR_LISTRADIOCHECKBOXES="Is Not (only 4 list/radio/checkboxes)"
|
||||
COM_COMPONENTBUILDER_IS_ONLY_FOUR_LISTRADIOCHECKBOXES="Is (only 4 list/radio/checkboxes)"
|
||||
COM_COMPONENTBUILDER_JCB_COMMUNITY="JCB Community"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT="Joomla Component"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENTS="Joomla Components"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_ACCESS="Joomla Components Access"
|
||||
@ -4736,6 +4754,7 @@ COM_COMPONENTBUILDER_LIBRARY_VERSION_LABEL="Revision"
|
||||
COM_COMPONENTBUILDER_LICENSE="License"
|
||||
COM_COMPONENTBUILDER_LICENSE_S="License: %s"
|
||||
COM_COMPONENTBUILDER_LINK="Link"
|
||||
COM_COMPONENTBUILDER_LINK_TO_THE_CONTRIBUTOR="Link to the contributor"
|
||||
COM_COMPONENTBUILDER_MAIN_MENU="Main Menu"
|
||||
COM_COMPONENTBUILDER_MATCH_BEHAVIOR="Match Behavior"
|
||||
COM_COMPONENTBUILDER_MATCH_FIELD="Match Field"
|
||||
@ -4757,6 +4776,7 @@ COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_FOR_S="No cronjob path found for (%s)
|
||||
COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_SINCE_INCORRECT_TYPE_REQUESTED="No cronjob path found since incorrect type requested."
|
||||
COM_COMPONENTBUILDER_NO_ITEM_FOUND="No Item Found"
|
||||
COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY="No keys were found. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key."
|
||||
COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION="No need to get it since it is already in sync with your local version"
|
||||
COM_COMPONENTBUILDER_NO_SNIPPETS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN="No snippets were selected, please make a selection and try again!"
|
||||
COM_COMPONENTBUILDER_NO_S_FOUND="No %s Found"
|
||||
COM_COMPONENTBUILDER_NO_S_HAVE_BEEN_LINKED_TO_THIS_VIEW_SOON_AS_THIS_IS_DONE_IT_WILL_BE_DISPLAYED_HERE="No %s have been linked to this view. Soon as this is done it will be displayed here."
|
||||
@ -5297,6 +5317,7 @@ COM_COMPONENTBUILDER_SNIPPETS_N_ITEMS_UNPUBLISHED="%s Snippets unpublished."
|
||||
COM_COMPONENTBUILDER_SNIPPETS_N_ITEMS_UNPUBLISHED_1="%s Snippet unpublished."
|
||||
COM_COMPONENTBUILDER_SNIPPETS_SUBMENU="Snippets Submenu"
|
||||
COM_COMPONENTBUILDER_SNIPPETS_SUBMENU_DESC="Allows the users in this group to update the submenu of the snippet"
|
||||
COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED="Snippet could not be updated/saved"
|
||||
COM_COMPONENTBUILDER_SNIPPET_CREATED_BY_DESC="The user that created this Snippet."
|
||||
COM_COMPONENTBUILDER_SNIPPET_CREATED_BY_LABEL="Created By"
|
||||
COM_COMPONENTBUILDER_SNIPPET_CREATED_DATE_DESC="The date this Snippet was created."
|
||||
@ -5438,6 +5459,8 @@ COM_COMPONENTBUILDER_SUBMENU_LAYOUTS="Layouts"
|
||||
COM_COMPONENTBUILDER_SUBMENU_SITE_VIEWS="Site Views"
|
||||
COM_COMPONENTBUILDER_SUBMENU_SNIPPETS="Snippets"
|
||||
COM_COMPONENTBUILDER_SUBMENU_TEMPLATES="Templates"
|
||||
COM_COMPONENTBUILDER_SUCCESS_THE_SNIPPET_WAS_SAVED="Success! The snippet was saved."
|
||||
COM_COMPONENTBUILDER_SUCCESS_THE_SNIPPET_WAS_SAVED_BUT_THE_MODIFIED_DATE_COULD_NOT_BE_ADJUSTED_BR_BR_BTHIS_MEANS_THE_SNIPPETS_WILL_CONTINUE_TO_APPEAR_OUT_OF_DATEB="Success! The snippet was saved. But the modified date could not be adjusted. <br /><br /><b>This means the snippets will continue to appear out of date.</b>"
|
||||
COM_COMPONENTBUILDER_S_BEING_IMPORTED="%s Being Imported"
|
||||
COM_COMPONENTBUILDER_S_PLEASE_WAIT_THE_COMPONENT_IS_BEING_COMPILED="%s, please wait! The component is being compiled"
|
||||
COM_COMPONENTBUILDER_TAB="Tab"
|
||||
@ -5581,6 +5604,7 @@ COM_COMPONENTBUILDER_TYPE_ERROR="Type Error"
|
||||
COM_COMPONENTBUILDER_UNACTIVE_ONLY_FOUR_TEXT_FIELD="Unactive (only 4 text_field)"
|
||||
COM_COMPONENTBUILDER_UNDERNEATH_TABS="Underneath Tabs"
|
||||
COM_COMPONENTBUILDER_UP_TO_DATE="Up to date"
|
||||
COM_COMPONENTBUILDER_USAGE="Usage"
|
||||
COM_COMPONENTBUILDER_USED_IN="used in"
|
||||
COM_COMPONENTBUILDER_USE_BATCH="Use Batch"
|
||||
COM_COMPONENTBUILDER_USE_BATCH_DESC=" Allows users in this group to use batch copy/update method."
|
||||
@ -5589,8 +5613,15 @@ COM_COMPONENTBUILDER_VDM_NOTICE_BOARD="VDM Notice Board"
|
||||
COM_COMPONENTBUILDER_VERSION="Version"
|
||||
COM_COMPONENTBUILDER_VIEW="View"
|
||||
COM_COMPONENTBUILDER_VIEWS="Views"
|
||||
COM_COMPONENTBUILDER_VIEW_BLAME="View Blame"
|
||||
COM_COMPONENTBUILDER_VIEW_DESCRIPTION_OF_COMMUNITY_VERSION="View Description of community version"
|
||||
COM_COMPONENTBUILDER_VIEW_MORE_ISSUES_ON_GITHUB="View more issues on Github"
|
||||
COM_COMPONENTBUILDER_VIEW_MORE_RELEASES_ON_GITHUB="View more releases on Github"
|
||||
COM_COMPONENTBUILDER_VIEW_SNIPPET_OF_COMMUNITY_VERSION="View Snippet of community version"
|
||||
COM_COMPONENTBUILDER_VIEW_SNIPPET_REFERENCE_URL="View Snippet Reference URL"
|
||||
COM_COMPONENTBUILDER_VIEW_THE_CONTRIBUTOR_DETAILS="View the contributor details"
|
||||
COM_COMPONENTBUILDER_VIEW_USAGE_OF_COMMUNITY_VERSION="View Usage of community version"
|
||||
COM_COMPONENTBUILDER_VIEW_WHO_CONTRIBUTED_TO_THIS_SNIPPET="View who contributed to this snippet"
|
||||
COM_COMPONENTBUILDER_WEBSITE="Website"
|
||||
COM_COMPONENTBUILDER_WEBSITE_S="Website: %s"
|
||||
COM_COMPONENTBUILDER_WE_FAILED_TO_MOVE_BSB="We failed to move <b>%s</b>!"
|
||||
|
@ -1733,6 +1733,140 @@ class ComponentbuilderModelAjax extends JModelList
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setSnippetGithub($path, $status)
|
||||
{
|
||||
// get user
|
||||
$user = JFactory::getUser();
|
||||
$access = $user->authorise('snippet.access', 'com_componentbuilder');
|
||||
if ($access)
|
||||
{
|
||||
// secure path
|
||||
$path = ComponentbuilderHelper::safeString(str_replace('.json','',$path), 'filename', '', false).'.json';
|
||||
// set url
|
||||
$url = 'https://raw.githubusercontent.com/vdm-io/Joomla-Component-Builder-Snippets/master/'.rawurlencode(basename($path));
|
||||
// get the snippets
|
||||
$snippet = ComponentbuilderHelper::getFileContents($url);
|
||||
if (ComponentbuilderHelper::checkJson($snippet))
|
||||
{
|
||||
return $this->saveSnippet(json_decode($snippet, true), $status, $user);
|
||||
}
|
||||
return array('message' => JText::_('COM_COMPONENTBUILDER_ERROR_THE_PATH_HAS_A_MISMATCH_AND_COULD_THEREFORE_NOT_RETRIEVE_THE_SNIPPET_FROM_GITHUB'), 'status' => 'danger');
|
||||
}
|
||||
return array('message' => JText::_('COM_COMPONENTBUILDER_ERROR_YOU_DO_NOT_HAVE_ACCESS_TO_THE_SNIPPETS'), 'status' => 'danger');
|
||||
}
|
||||
|
||||
protected function saveSnippet($item, $status, $user)
|
||||
{
|
||||
// set some defaults
|
||||
$todayDate = JFactory::getDate()->toSql();
|
||||
// get the type id
|
||||
$item['type'] = ($id = ComponentbuilderHelper::getVar('snippet_type', $item['type'], 'name', 'id')) ? $id : $this->createNew($item['type'], 'snippet_type', $user, $todayDate);
|
||||
// get the library id
|
||||
$item['library'] = ($id = ComponentbuilderHelper::getVar('library', $item['library'], 'name', 'id')) ? $id : $this->createNew($item['library'], 'library', $user, $todayDate);
|
||||
// remove type if zero
|
||||
if ($item['type'] == 0)
|
||||
{
|
||||
unset($item['type']);
|
||||
}
|
||||
// remove library if zero
|
||||
if ($item['library'] == 0)
|
||||
{
|
||||
unset($item['library']);
|
||||
}
|
||||
// get the snippet ID
|
||||
$item['id'] = $this->getSnippetId($item);
|
||||
if ($item['id'] == 0)
|
||||
{
|
||||
$canCreate = $user->authorise('snippet.create', 'com_componentbuilder');
|
||||
if ('new' === $status && !$canCreate)
|
||||
{
|
||||
return array('message' => JText::_('COM_COMPONENTBUILDER_ERROR_YOU_DO_NOT_HAVE_PERMISSION_TO_CREATE_THE_SNIPPET'), 'status' => 'danger');
|
||||
}
|
||||
}
|
||||
// get the snippet model
|
||||
$model = ComponentbuilderHelper::getModel('snippet', JPATH_COMPONENT_ADMINISTRATOR);
|
||||
// save the snippet
|
||||
if ($model->save($item))
|
||||
{
|
||||
if ($item['id'] == 0)
|
||||
{
|
||||
// get the saved item
|
||||
$updatedItem = $model->getItem();
|
||||
$item['id']= $updatedItem->get('id');
|
||||
}
|
||||
// we have to force modified date since the model does not allow you
|
||||
if ($this->forchDateFix($item))
|
||||
{
|
||||
return array('message' => JText::_('COM_COMPONENTBUILDER_SUCCESS_THE_SNIPPET_WAS_SAVED'), 'status' => 'success');
|
||||
}
|
||||
// return error
|
||||
return array('message' => JText::_('COM_COMPONENTBUILDER_SUCCESS_THE_SNIPPET_WAS_SAVED_BUT_THE_MODIFIED_DATE_COULD_NOT_BE_ADJUSTED_BR_BR_BTHIS_MEANS_THE_SNIPPETS_WILL_CONTINUE_TO_APPEAR_OUT_OF_DATEB'), 'status' => 'warning');
|
||||
}
|
||||
// return error
|
||||
return array('message' => JText::_('COM_COMPONENTBUILDER_ERROR_THE_SNIPPET_IS_FAULTY_AND_COULD_NOT_BE_SAVED'), 'status' => 'danger');
|
||||
}
|
||||
|
||||
protected function forchDateFix($item)
|
||||
{
|
||||
$object = new stdClass();
|
||||
$object->id = (int) $item['id'];
|
||||
$object->created = $item['created'];
|
||||
$object->modified = $item['modified'];
|
||||
// force update
|
||||
return JFactory::getDbo()->updateObject('#__componentbuilder_snippet', $object, 'id');
|
||||
}
|
||||
|
||||
protected function getSnippetId($item)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('a.id')));
|
||||
$query->from($db->quoteName('#__componentbuilder_snippet', 'a'));
|
||||
$query->where($db->quoteName('a.name') . ' = ' . (string) $db->quote($item['name']));
|
||||
if (is_numeric($item['type']))
|
||||
{
|
||||
$query->where($db->quoteName('a.type') . ' = ' . (int) $item['type']);
|
||||
}
|
||||
if (is_numeric($item['library']))
|
||||
{
|
||||
$query->where($db->quoteName('a.library') . ' = ' . (int) $item['library']);
|
||||
}
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadResult();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function createNew($name, $type, $user, $todayDate)
|
||||
{
|
||||
// verify that we can continue
|
||||
if (ComponentbuilderHelper::getActions($type)->get('core.create'))
|
||||
{
|
||||
// get the snippet model
|
||||
$model = ComponentbuilderHelper::getModel($type, JPATH_COMPONENT_ADMINISTRATOR);
|
||||
// build array to save
|
||||
$item['id'] = 0;
|
||||
$item['name'] = $name;
|
||||
$item['published'] = 1;
|
||||
$item['version'] = 1;
|
||||
$item['created'] = $todayDate;
|
||||
$item['created_by'] = $user->id;
|
||||
// save the new
|
||||
$model->save($item);
|
||||
// get the saved item
|
||||
$item = $model->getItem();
|
||||
return $item->get('id');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Used in field
|
||||
public function getFieldOptions($id)
|
||||
{
|
||||
|
@ -1188,7 +1188,7 @@ INSERT INTO `#__componentbuilder_snippet` (`id`, `description`, `library`, `head
|
||||
(2, 'UIkit uses panels to outline certain sections of your content, which can be styled differently. Typically, panels are arranged in grid columns from the Grid component.', 4, 'Create layout boxes with different styles.', 'Panel', 'PGRpdiBkYXRhLXVrLWdyaWQtbWFyZ2luPSIiIGNsYXNzPSJ1ay1ncmlkIj4NCiAgICA8ZGl2IGNsYXNzPSJ1ay13aWR0aC1tZWRpdW0tMS0yIj4NCiAgICAgICAgPGRpdiBjbGFzcz0idWstcGFuZWwgdWstcGFuZWwtYm94Ij4NCiAgICAgICAgICAgIDxoMyBjbGFzcz0idWstcGFuZWwtdGl0bGUiPnt0aXRsZX08L2gzPg0KICAgICAgICAgICAge2NvbnRlbnR9DQogICAgICAgIDwvZGl2Pg0KICAgIDwvZGl2Pg0KICAgIDxkaXYgY2xhc3M9InVrLXdpZHRoLW1lZGl1bS0xLTIiPg0KICAgICAgICA8ZGl2IGNsYXNzPSJ1ay1wYW5lbCB1ay1wYW5lbC1ib3giPg0KICAgICAgICAgICAgPGgzIGNsYXNzPSJ1ay1wYW5lbC10aXRsZSI+e3RpdGxlfTwvaDM+DQogICAgICAgICAgICB7Y29udGVudH0NCiAgICAgICAgPC9kaXY+DQogICAgPC9kaXY+DQo8L2Rpdj4=', 1, 'http://getuikit.com/docs/panel.html', 'The Panel component consists of the panel itself, the panel title and a panel badge. To prevent redundant white space, top and bottom margins are removed from the panel\'s content.', '', 1, 3, '', 1),
|
||||
(3, '', 4, 'Separate content sections by bundling them in blocks with different styles.', 'Block', 'PGRpdiBjbGFzcz0idWstYmxvY2sgdWstYmxvY2stcHJpbWFyeSI+e2NvbnRlbnR9PC9kaXY+', 1, 'http://getuikit.com/docs/block.html', 'To apply this component, just add the .uk-block class to a container element.', '', 1, 2, '', 2),
|
||||
(4, '', 4, 'Create articles within your page.', 'Article', 'PGFydGljbGUgY2xhc3M9InVrLWFydGljbGUiPg0KICAgIDxoMSBjbGFzcz0idWstYXJ0aWNsZS10aXRsZSI+e3RpdGxlfTwvaDE+DQogICAgPHAgY2xhc3M9InVrLWFydGljbGUtbWV0YSI+e21ldGF9PC9wPg0KICAgIDxwIGNsYXNzPSJ1ay1hcnRpY2xlLWxlYWQiPntjb250ZW50fTwvcD4NCiAgICB7Y29udGVudH0NCiAgICA8aHIgY2xhc3M9InVrLWFydGljbGUtZGl2aWRlciI+DQogICAge2NvbnRlbnR9DQo8L2FydGljbGU+', 1, 'http://getuikit.com/docs/article.html', 'The article component consists of the article itself, a title, meta data, an opening paragraph and dividers.', '', 1, 1, '', 3),
|
||||
(5, '', 4, 'Create comments, for example about articles.', 'Comment', 'PGFydGljbGUgY2xhc3M9InVrLWNvbW1lbnQiPg0KICAgIDxoZWFkZXIgY2xhc3M9InVrLWNvbW1lbnQtaGVhZGVyIj4NCiAgICAgICAgPGltZyBjbGFzcz0idWstY29tbWVudC1hdmF0YXIiIHNyYz0ie2ltYWdldXJsfSIgYWx0PSIiPg0KICAgICAgICA8aDQgY2xhc3M9InVrLWNvbW1lbnQtdGl0bGUiPnt0aXRsZX08L2g0Pg0KICAgICAgICA8ZGl2IGNsYXNzPSJ1ay1jb21tZW50LW1ldGEiPnttZXRhfTwvZGl2Pg0KICAgIDwvaGVhZGVyPg0KICAgIDxkaXYgY2xhc3M9InVrLWNvbW1lbnQtYm9keSI+e3RpdGxlfTwvZGl2Pg0KPC9hcnRpY2xlPg==', 1, 'http://getuikit.com/docs/comment.html', 'The Comment component consists of a comment header, including an avatar, a title and meta data, and a comment body.', '', 1, 1, '', 4),
|
||||
(5, '', 4, 'Create comments, for example about articles.', 'Comment', 'PGFydGljbGUgY2xhc3M9InVrLWNvbW1lbnQiPg0KICAgIDxoZWFkZXIgY2xhc3M9InVrLWNvbW1lbnQtaGVhZGVyIj4NCiAgICAgICAgPGltZyBjbGFzcz0idWstY29tbWVudC1hdmF0YXIiIHNyYz0ie2ltYWdldXJsfSIgYWx0PSIiPg0KICAgICAgICA8aDQgY2xhc3M9InVrLWNvbW1lbnQtdGl0bGUiPnt0aXRsZX08L2g0Pg0KICAgICAgICA8ZGl2IGNsYXNzPSJ1ay1jb21tZW50LW1ldGEiPnttZXRhfTwvZGl2Pg0KICAgIDwvaGVhZGVyPg0KICAgIDxkaXYgY2xhc3M9InVrLWNvbW1lbnQtYm9keSI+e3RpdGxlfTwvZGl2Pg0KPC9hcnRpY2xlPg==', 1, 'http://getuikit.com/docs/comment.html', 'The Comment component consists of a comment header, including an avatar, a title and meta data, and a comment body.', '', 1, 2, '', 4),
|
||||
(6, '', 4, 'A collection of useful utility classes to style your content.', 'Utility Container', 'PGRpdiBjbGFzcz0idWstd2lkdGgtbWVkaXVtLTEtMiB1ay1jb250YWluZXItY2VudGVyIj57Y29udGVudH08L2Rpdj4=', 1, 'http://getuikit.com/docs/utility.html', 'Add the .uk-container class to a block element to give it a max-width and wrap the main content of your website. For large screens it applies a different max-width.\r\n\r\nTo center the container, use the .uk-container-center class. For any other block element, you additionally need to apply a width.', '', 1, 2, '', 5),
|
||||
(7, '', 4, 'A collection of useful utility classes to style your content.', 'Utility Clearing and floating', 'PGRpdiBjbGFzcz0idWstY2xlYXJmaXgiPg0KICAgIDxkaXYgY2xhc3M9InVrLWZsb2F0LXJpZ2h0Ij57Y29udGVudH08L2Rpdj4NCiAgICA8ZGl2IGNsYXNzPSJ1ay1mbG9hdC1sZWZ0Ij57Y29udGVudH08L2Rpdj4NCjwvZGl2Pg==', 1, 'http://getuikit.com/docs/utility.html', 'Floating is fundamental for creating all kinds of layouts. But floats need to be cleared or in the worst case, you might end up with a scrambled site. The following classes will help you to setup basic layouts.', '', 1, 2, '', 5),
|
||||
(8, 'This component uses Flexbox, a concept that is still quite new but extremely powerful for creating layouts.', 4, 'Utilize the power of Flexbox to create a wide range of layouts.', 'Flex', 'PGRpdiBjbGFzcz0idWstZmxleCB1ay1mbGV4LXdyYXAgdWstZmxleC13cmFwLXJldmVyc2UgdWstZmxleC13cmFwLXNwYWNlLWFyb3VuZCI+DQogICAgPGRpdiBjbGFzcz0idWstd2lkdGgtMS0zIHVrLXBhbmVsIHVrLXBhbmVsLWJveCB1ay1wYW5lbC1ib3gtcHJpbWFyeSI+e2NvbnRlbnR9PC9kaXY+DQogICAgPGRpdiBjbGFzcz0idWstd2lkdGgtMS0yIHVrLXBhbmVsIHVrLXBhbmVsLWJveCB1ay1wYW5lbC1ib3gtcHJpbWFyeSB1ay1tYXJnaW4tbGVmdCI+e2NvbnRlbnR9PC9kaXY+DQogICAgPGRpdiBjbGFzcz0idWstd2lkdGgtMS0zIHVrLXBhbmVsIHVrLXBhbmVsLWJveCB1ay1wYW5lbC1ib3gtcHJpbWFyeSI+e2NvbnRlbnR9PC9kaXY+DQogICAgPGRpdiBjbGFzcz0idWstd2lkdGgtMS0zIHVrLXBhbmVsIHVrLXBhbmVsLWJveCB1ay1wYW5lbC1ib3gtcHJpbWFyeSB1ay1tYXJnaW4tbGVmdCI+e2NvbnRlbnR9PC9kaXY+DQogICAgPGRpdiBjbGFzcz0idWstd2lkdGgtMS0yIHVrLXBhbmVsIHVrLXBhbmVsLWJveCB1ay1wYW5lbC1ib3gtcHJpbWFyeSI+e2NvbnRlbnR9PC9kaXY+DQogICAgPGRpdiBjbGFzcz0idWstd2lkdGgtMS0zIHVrLXBhbmVsIHVrLXBhbmVsLWJveCB1ay1wYW5lbC1ib3gtcHJpbWFyeSB1ay1tYXJnaW4tbGVmdCI+e2NvbnRlbnR9PC9kaXY+DQo8L2Rpdj4=', 1, 'http://getuikit.com/docs/flex.html', 'To apply this component, just add the .uk-flex class to a element. This will create the flex container. By default, all flex items will be aligned to the left and equally matched in height and width.', '', 1, 3, '', 5),
|
||||
@ -1272,7 +1272,7 @@ INSERT INTO `#__componentbuilder_snippet` (`id`, `description`, `library`, `head
|
||||
(86, 'You can link multiple images to the same lightbox and switch between them from within the lightbox, thus creating a gallery. Just add the {group:\'my-group\'} option to the data attribute of each item using the same name on all items that you want to group. Make sure to include the CSS from the Slidenav component, so you can navigate between the items.', 4, 'Create a fancy lightbox for images and videos utilizing the Modal component.', 'Lightbox groups-image', 'PGRpdiBkYXRhLXVrLWdyaWQtbWFyZ2luPSIiIGNsYXNzPSJ1ay1ncmlkIHVrLWdyaWQtd2lkdGgtbWVkaXVtLTEtNCI+DQogICAgPGRpdj4NCiAgICAgICAgPGEgdGl0bGU9IlRpdGxlIiBkYXRhLXVrLWxpZ2h0Ym94PSJ7Z3JvdXA6J2dyb3VwMSd9IiBocmVmPSJpbWFnZXMvcGxhY2Vob2xkZXJfODAweDYwMF8xLmpwZyI+DQogICAgICAgICAgICA8aW1nIHdpZHRoPSI4MDAiIGhlaWdodD0iNjAwIiBhbHQ9IiIgc3JjPSJpbWFnZXMvcGxhY2Vob2xkZXJfODAweDYwMF8xLmpwZyI+DQogICAgICAgIDwvYT4NCiAgICA8L2Rpdj4NCiAgICA8ZGl2Pg0KICAgICAgICA8YSB0aXRsZT0iVGl0bGUiIGRhdGEtdWstbGlnaHRib3g9Intncm91cDonZ3JvdXAxJ30iIGRhdGEtbGlnaHRib3gtdHlwZT0iaW1hZ2UiIGhyZWY9ImltYWdlcy9wbGFjZWhvbGRlcl84MDB4NjAwXzIuanBnIj4NCiAgICAgICAgICAgIDxpbWcgd2lkdGg9IjgwMCIgaGVpZ2h0PSI2MDAiIGFsdD0iIiBzcmM9ImltYWdlcy9wbGFjZWhvbGRlcl84MDB4NjAwXzIuanBnIj4NCiAgICAgICAgPC9hPg0KICAgIDwvZGl2Pg0KICAgIDxkaXY+DQogICAgICAgIDxhIHRpdGxlPSJUaXRsZSIgZGF0YS11ay1saWdodGJveD0ie2dyb3VwOidncm91cDEnfSIgZGF0YS1saWdodGJveC10eXBlPSJpbWFnZSIgaHJlZj0iaW1hZ2VzL3BsYWNlaG9sZGVyXzgwMHg2MDBfMy5qcGciPg0KICAgICAgICAgICAgPGltZyB3aWR0aD0iODAwIiBoZWlnaHQ9IjYwMCIgYWx0PSIiIHNyYz0iaW1hZ2VzL3BsYWNlaG9sZGVyXzgwMHg2MDBfMy5qcGciPg0KICAgICAgICA8L2E+DQogICAgPC9kaXY+DQogICAgPGRpdj4NCiAgICAgICAgPGEgdGl0bGU9IlRpdGxlIiBkYXRhLXVrLWxpZ2h0Ym94PSJ7Z3JvdXA6J2dyb3VwMSd9IiBkYXRhLWxpZ2h0Ym94LXR5cGU9ImltYWdlIiBocmVmPSJpbWFnZXMvcGxhY2Vob2xkZXJfODAweDYwMF80LmpwZyI+DQogICAgICAgICAgICA8aW1nIHdpZHRoPSI4MDAiIGhlaWdodD0iNjAwIiBhbHQ9IiIgc3JjPSJpbWFnZXMvcGxhY2Vob2xkZXJfODAweDYwMF80LmpwZyI+DQogICAgICAgIDwvYT4NCiAgICA8L2Rpdj4NCjwvZGl2Pg==', 5, 'http://getuikit.com/docs/lightbox.html', 'To apply this component, add the data-uk-lightbox attribute to an anchor linking to the image you wish to display. If a title attribute exists it will be displayed as a caption for the lightbox.', '', 1, 2, '', 9),
|
||||
(87, 'A lightbox is not restricted to images. Other media, like videos, can be displayed inside a lightbox and it will automatically generate the correct output by evaluating your path.', 4, 'Create a fancy lightbox for images and videos utilizing the Modal component.', 'Lightbox content-sources', 'PHA+DQogICAgPGEgdGl0bGU9IlRpdGxlIiBkYXRhLXVrLWxpZ2h0Ym94PSJ7Z3JvdXA6J2dyb3VwMid9IiBocmVmPSJpbWFnZXMvcGxhY2Vob2xkZXJfODAweDYwMF8xLmpwZyIgY2xhc3M9InVrLWJ1dHRvbiI+SW1hZ2U8L2E+DQogICAgPGEgZGF0YS11ay1saWdodGJveD0ie2dyb3VwOidncm91cDInfSIgaHJlZj0iaHR0cDovL3d3dy5xdWlya3Ntb2RlLm9yZy9odG1sNS92aWRlb3MvYmlnX2J1Y2tfYnVubnkubXA0IiBjbGFzcz0idWstYnV0dG9uIj5NUDQ8L2E+DQogICAgPGEgZGF0YS11ay1saWdodGJveD0ie2dyb3VwOidncm91cDInfSIgaHJlZj0iaHR0cDovL3ZpbWVvLmNvbS8xMDg0NTM3IiBjbGFzcz0idWstYnV0dG9uIj5WaW1lbzwvYT4NCiAgICA8YSBkYXRhLXVrLWxpZ2h0Ym94PSJ7Z3JvdXA6J2dyb3VwMid9IiBocmVmPSJodHRwczovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PVlFN1Z6bEx0cC00IiBjbGFzcz0idWstYnV0dG9uIj5Zb3VUdWJlPC9hPg0KPC9wPg==', 5, 'http://getuikit.com/docs/lightbox.html', 'To apply this component, add the data-uk-lightbox attribute to an anchor linking to the image you wish to display. If a title attribute exists it will be displayed as a caption for the lightbox.', '', 1, 1, '', 9),
|
||||
(88, 'To display multiple content sections at the same time without one collapsing when the other one is opened, add the {collapse: false} option to the date attribute.', 4, 'Create a list of items, allowing each item\'s content to be expanded and collapsed by clicking its header.', 'Accordion', 'PGRpdiBjbGFzcz0idWstYWNjb3JkaW9uIiBkYXRhLXVrLWFjY29yZGlvbj4NCg0KICAgIDxoMyBjbGFzcz0idWstYWNjb3JkaW9uLXRpdGxlIj4uLi48L2gzPg0KICAgIDxkaXYgY2xhc3M9InVrLWFjY29yZGlvbi1jb250ZW50Ij4uLi48L2Rpdj4NCg0KICAgIDxoMyBjbGFzcz0idWstYWNjb3JkaW9uLXRpdGxlIj4uLi48L2gzPg0KICAgIDxkaXYgY2xhc3M9InVrLWFjY29yZGlvbi1jb250ZW50Ij4uLi48L2Rpdj4NCg0KICAgIDxoMyBjbGFzcz0idWstYWNjb3JkaW9uLXRpdGxlIj4uLi48L2gzPg0KICAgIDxkaXYgY2xhc3M9InVrLWFjY29yZGlvbi1jb250ZW50Ij4uLi48L2Rpdj4NCg0KPC9kaXY+', 5, 'http://getuikit.com/docs/accordion.html', 'To apply the Accordion component, add the uk-accordion class and the data-uk-accordion attribute to a container element. Add the uk-accordion-content class to each of the content sections within the container. Finally, add the uk-accordion-title class to any element, like a heading, above the content section to create a toggle.', '', 1, 3, '', 10),
|
||||
(89, 'FooTable is a jQuery plugin that aims to make HTML tables on smaller devices look awesome – No matter how many columns of data you may have in them.\r\n\r\nHave you ever wanted to show a lot of data in a table, but hate how badly it scales on smaller mobile devices? The FooTable jQuery plugin solves this problem by allowing you to hide certain columns on smaller devices, but still allowing the user to expand each row to see the columns that were hidden.', 5, 'FooTable', 'FooTable', 'PHRhYmxlIGNsYXNzPSJmb290YWJsZSBtZXRyby1ibHVlIiBkYXRhLWZpbHRlcj0iI2ZpbHRlciIgZGF0YS1wYWdlLXNpemU9IjUiPg0KICA8dGhlYWQ+DQogICAgPHRyPg0KICAgICAgPHRoIGRhdGEtdG9nZ2xlPSJ0cnVlIj5OYW1lPC90aD4NCiAgICAgIDx0aCBkYXRhLWhpZGU9InBob25lLHRhYmxldCI+UGhvbmU8L3RoPg0KICAgICAgPHRoIGRhdGEtaGlkZT0icGhvbmUsdGFibGV0Ij5FbWFpbDwvdGg+DQogICAgPC90cj4NCiAgPC90aGVhZD4NCiAgPHRib2R5Pg0KICAgIDx0cj4NCiAgICAgIDx0ZD5Cb2IgTWFuPC90ZD4NCiAgICAgIDx0ZD41NTUtMTIzNDU8L3RkPg0KICAgICAgPHRkPmJvYkBob21lLmNvbTwvdGQ+DQogICAgPC90cj4NCiAgICA8dHI+DQogICAgICA8dGQ+QnJpZGdldCBKb25lczwvdGQ+DQogICAgICA8dGQ+NTQ0LTc3NjY1NTwvdGQ+DQogICAgICA8dGQ+YmpvbmVzQG15c2l0ZS5jb208L3RkPg0KICAgIDwvdHI+DQogICAgPHRyPg0KICAgICAgPHRkPlRvbSBKb25lczwvdGQ+DQogICAgICA8dGQ+NTU1LTk5OTExPC90ZD4NCiAgICAgIDx0ZD5jcnVpc2UxQGNyYXp5LmNvbTwvdGQ+DQogICAgPC90cj4NCiAgPC90Ym9keT4NCjwvdGFibGU+', 1, 'http://fooplugins.com/footable-demos/', '', '', 1, 3, '', 11),
|
||||
(93, 'FooTable is a jQuery plugin that aims to make HTML tables on smaller devices look awesome – No matter how many columns of data you may have in them.\r\n\r\nHave you ever wanted to show a lot of data in a table, but hate how badly it scales on smaller mobile devices? The FooTable jQuery plugin solves this problem by allowing you to hide certain columns on smaller devices, but still allowing the user to expand each row to see the columns that were hidden.', 5, 'FooTable', 'FooTable', 'PHRhYmxlIGNsYXNzPSJmb290YWJsZSBtZXRyby1ibHVlIiBkYXRhLWZpbHRlcj0iI2ZpbHRlciIgZGF0YS1wYWdlLXNpemU9IjUiPg0KICA8dGhlYWQ+DQogICAgPHRyPg0KICAgICAgPHRoIGRhdGEtdG9nZ2xlPSJ0cnVlIj5OYW1lPC90aD4NCiAgICAgIDx0aCBkYXRhLWhpZGU9InBob25lLHRhYmxldCI+UGhvbmU8L3RoPg0KICAgICAgPHRoIGRhdGEtaGlkZT0icGhvbmUsdGFibGV0Ij5FbWFpbDwvdGg+DQogICAgPC90cj4NCiAgPC90aGVhZD4NCiAgPHRib2R5Pg0KICAgIDx0cj4NCiAgICAgIDx0ZD5Cb2IgTWFuPC90ZD4NCiAgICAgIDx0ZD41NTUtMTIzNDU8L3RkPg0KICAgICAgPHRkPmJvYkBob21lLmNvbTwvdGQ+DQogICAgPC90cj4NCiAgICA8dHI+DQogICAgICA8dGQ+QnJpZGdldCBKb25lczwvdGQ+DQogICAgICA8dGQ+NTQ0LTc3NjY1NTwvdGQ+DQogICAgICA8dGQ+YmpvbmVzQG15c2l0ZS5jb208L3RkPg0KICAgIDwvdHI+DQogICAgPHRyPg0KICAgICAgPHRkPlRvbSBKb25lczwvdGQ+DQogICAgICA8dGQ+NTU1LTk5OTExPC90ZD4NCiAgICAgIDx0ZD5jcnVpc2UxQGNyYXp5LmNvbTwvdGQ+DQogICAgPC90cj4NCiAgPC90Ym9keT4NCjwvdGFibGU+', 1, 'http://fooplugins.com/footable-demos/', '', '', 1, 5, '', 13),
|
||||
(90, 'This is a input field for uikit form', 4, 'Add Input field - row', 'Input field', 'ICAgICAgICA8ZGl2IGNsYXNzPSJ1ay1mb3JtLXJvdyI+DQoJCTxsYWJlbCBjbGFzcz0idWstZm9ybS1sYWJlbCIgPg0KCQkJPD9waHAgZWNobyBKVGV4dDo6XygnTGFiZWwnKTsgPz4NCgkJPC9sYWJlbD4NCgkJPGlucHV0IHR5cGU9InRleHQiIG5hbWU9ImtleSIgcGxhY2Vob2xkZXI9Ijw/cGhwIGVjaG8gSlRleHQ6Ol8oJ2FkZCBzb21lIHRleHQgaGVyZSEnKTsgPz4iPiA8c3BhbiBjbGFzcz0idWstZm9ybS1oZWxwLWlubGluZSI+PD9waHAgZWNobyBKVGV4dDo6XygnaGVscCBuZWVkZWQnKTsgPz48L3NwYW4+DQoJPC9kaXY+', 3, 'http://getuikit.com/docs/form.html', '', '', 1, 2, '', 12),
|
||||
(91, 'This is a textarea field for uikit form', 4, 'Add textarea - row', 'Textarea', 'CTxkaXYgY2xhc3M9InVrLWZvcm0tcm93Ij4NCgkJPGxhYmVsIGNsYXNzPSJ1ay1mb3JtLWxhYmVsIiA+DQoJCQk8P3BocCBlY2hvIEpUZXh0OjpfKCdMYWJlbCcpOyA/Pg0KCQk8L2xhYmVsPg0KCQk8dGV4dGFyZWEgY29scz0iIiByb3dzPSIiICBzdHlsZT0id2lkdGg6IDEwMCU7IGhlaWdodDogMjE2cHg7IiBwbGFjZWhvbGRlcj0iPD9waHAgZWNobyBKVGV4dDo6XygnYWRkIHNvbWUgdGV4dCBoZXJlIScpOyA/PiI+PHx8fHxGSVh8fHx8fHx0ZXh0YXJlYT4NCgkJPHAgY2xhc3M9InVrLWZvcm0taGVscC1ibG9jayI+PD9waHAgZWNobyBKVGV4dDo6XygnaGVscCBuZWVkZWQnKTsgPz48L3A+DQoJPC9kaXY+', 3, 'http://getuikit.com/docs/form.html', '', '', 1, 4, '', 12),
|
||||
(92, 'This is a uikit form', 4, 'Add Form', 'Form', 'PGZvcm0gY2xhc3M9InVrLWZvcm0iPg0KICAgIDxmaWVsZHNldD4NCiAgICAgICAgPGxlZ2VuZD48P3BocCBlY2hvIEpUZXh0OjpfKCdMZWdlbmQnKTsgPz48L2xlZ2VuZD4NCiAgICAgICAgPGRpdiBjbGFzcz0idWstZm9ybS1yb3ciPg0KCQk8bGFiZWwgY2xhc3M9InVrLWZvcm0tbGFiZWwiID4NCgkJCTw/cGhwIGVjaG8gSlRleHQ6Ol8oJ0xhYmVsJyk7ID8+DQoJCTwvbGFiZWw+DQoJCTxpbnB1dCB0eXBlPSJ0ZXh0IiBuYW1lPSJrZXkiIHBsYWNlaG9sZGVyPSI8P3BocCBlY2hvIEpUZXh0OjpfKCdhZGQgc29tZSB0ZXh0IGhlcmUhJyk7ID8+Ij4gPHNwYW4gY2xhc3M9InVrLWZvcm0taGVscC1pbmxpbmUiPjw/cGhwIGVjaG8gSlRleHQ6Ol8oJ2hlbHAgbmVlZGVkJyk7ID8+PC9zcGFuPg0KCTwvZGl2Pg0KICAgICAgICA8ZGl2IGNsYXNzPSJ1ay1mb3JtLXJvdyI+DQoJCTxsYWJlbCBjbGFzcz0idWstZm9ybS1sYWJlbCIgPg0KCQkJPD9waHAgZWNobyBKVGV4dDo6XygnTGFiZWwnKTsgPz4NCgkJPC9sYWJlbD4NCgkJPHRleHRhcmVhIGNvbHM9IiIgcm93cz0iIiAgc3R5bGU9IndpZHRoOiAxMDAlOyBoZWlnaHQ6IDIxNnB4OyIgcGxhY2Vob2xkZXI9Ijw/cGhwIGVjaG8gSlRleHQ6Ol8oJ2FkZCBzb21lIHRleHQgaGVyZSEnKTsgPz4iPjx8fHx8fEZJWHx8fHx8dGV4dGFyZWE+DQoJCTxwIGNsYXNzPSJ1ay1mb3JtLWhlbHAtYmxvY2siPjw/cGhwIGVjaG8gSlRleHQ6Ol8oJ2hlbHAgbmVlZGVkJyk7ID8+PC9wPg0KCTwvZGl2Pg0KICAgIDwvZmllbGRzZXQ+DQo8L2Zvcm0+', 1, 'http://getuikit.com/docs/form.html', '', '', 1, 2, '', 12);
|
||||
|
@ -55,7 +55,7 @@ JHtml::_('behavior.keepalive');
|
||||
</div>
|
||||
<div id="snippets-display" style="display: none;">
|
||||
<nav class="uk-navbar">
|
||||
<a href="https://github.com/vdm-io/Joomla-Component-Builder-Snippets" class="uk-navbar-brand uk-hidden-small" target="_blank"><i class="uk-icon-github"></i> gitHub</a>
|
||||
<a href="https://github.com/vdm-io/Joomla-Component-Builder-Snippets" class="uk-navbar-brand" target="_blank"><i class="uk-icon-github"></i> gitHub</a>
|
||||
<ul class="uk-navbar-nav uk-hidden-small snippets-menu">
|
||||
<li data-uk-filter=""><a href=""><?php echo JText::_('COM_COMPONENTBUILDER_ALL'); ?></a></li>
|
||||
<li data-uk-filter="equal"><a href=""><?php echo JText::_('COM_COMPONENTBUILDER_IN_SYNC'); ?></a></li>
|
||||
@ -70,23 +70,10 @@ JHtml::_('behavior.keepalive');
|
||||
<li data-uk-sort="snippet-types"><a href=""><?php echo JText::_('COM_COMPONENTBUILDER_TYPE_ASC'); ?></a></li>
|
||||
<li data-uk-sort="snippet-types:desc"><a href=""><?php echo JText::_('COM_COMPONENTBUILDER_TYPE_DESC'); ?></a></li>
|
||||
</ul>
|
||||
<a href="#small-snippets-menu" class="uk-navbar-toggle uk-visible-small" data-uk-offcanvas></a>
|
||||
</nav>
|
||||
<br />
|
||||
<div id="snippets-grid" class="uk-grid uk-grid-preserve uk-grid-width-small-1-1 uk-grid-width-medium-1-3 uk-grid-width-large-1-4" data-uk-grid="{gutter:10, controls: '.snippets-menu'}" data-uk-check-display></div>
|
||||
</div>
|
||||
<div id="small-snippets-menu" class="uk-offcanvas">
|
||||
<div class="uk-offcanvas-bar">
|
||||
<ul class="uk-nav uk-nav-offcanvas" data-uk-nav>
|
||||
<li data-uk-filter=""><a href="" class="uk-offcanvas-close"><?php echo JText::_('COM_COMPONENTBUILDER_ALL'); ?></a></li>
|
||||
<li data-uk-filter="equal"><a href="" class="uk-offcanvas-close"><?php echo JText::_('COM_COMPONENTBUILDER_IN_SYNC'); ?></a></li>
|
||||
<li data-uk-filter="behind"><a href="" class="uk-offcanvas-close"><?php echo JText::_('COM_COMPONENTBUILDER_OUT_OF_DATE'); ?></a></li>
|
||||
<li data-uk-filter="new"><a href="" class="uk-offcanvas-close"><?php echo JText::_('COM_COMPONENTBUILDER_NEW'); ?></a></li>
|
||||
<li data-uk-filter="diverged"><a href="" class="uk-offcanvas-close"><?php echo JText::_('COM_COMPONENTBUILDER_DIVERGED'); ?></a></li>
|
||||
<li data-uk-filter="ahead"><a href="" class="uk-offcanvas-close"><?php echo JText::_('COM_COMPONENTBUILDER_AHEAD'); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
// nice little dot trick :)
|
||||
|
@ -103,6 +103,8 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
{
|
||||
// Set the default uikit components in this view.
|
||||
$uikitComp = array();
|
||||
$uikitComp[] = 'UIkit.notify';
|
||||
$uikitComp[] = 'data-uk-tooltip';
|
||||
$uikitComp[] = 'data-uk-grid';
|
||||
}
|
||||
|
||||
@ -177,6 +179,52 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
$this->document->addScriptDeclaration("var token = '". JSession::getFormToken() ."';");
|
||||
// set an error message if needed
|
||||
$this->document->addScriptDeclaration("var returnError = '<div class=\"uk-alert uk-alert-warning\"><h1>".JText::_('COM_COMPONENTBUILDER_AN_ERROR_HAS_OCCURRED')."!</h1><p>".JText::_('COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_LATER').".</p></div>';");
|
||||
// need to add some language strings
|
||||
$this->document->addScriptDeclaration("var lang_Snippets = '".JText::_('COM_COMPONENTBUILDER_SNIPPETS')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Snippet = '".JText::_('COM_COMPONENTBUILDER_SNIPPET')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Snippet_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_SNIPPET_OF_COMMUNITY_VERSION')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Get_Snippet = '".JText::_('COM_COMPONENTBUILDER_GET_SNIPPET')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Get_Snippet_Tooltip = '".JText::_('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Get_Snippet_New_Tooltip = '".JText::_('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Get_Snippet_Dont_Tooltip = '".JText::_('COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Usage = '".JText::_('COM_COMPONENTBUILDER_USAGE')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Usage_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_USAGE_OF_COMMUNITY_VERSION')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Description = '".JText::_('COM_COMPONENTBUILDER_DESCRIPTION')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Description_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_DESCRIPTION_OF_COMMUNITY_VERSION')."';");
|
||||
$this->document->addScriptDeclaration("var lang_View_Blame = '".JText::_('COM_COMPONENTBUILDER_VIEW_BLAME')."';");
|
||||
$this->document->addScriptDeclaration("var lang_View_Blame_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_WHO_CONTRIBUTED_TO_THIS_SNIPPET')."';");
|
||||
$this->document->addScriptDeclaration("var lang_URL_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_SNIPPET_REFERENCE_URL')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Update_Error_Tooltip = '".JText::_('COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Contributor_URL_Tooltip = '".JText::_('COM_COMPONENTBUILDER_LINK_TO_THE_CONTRIBUTOR')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Contributor_Modal_Tooltip = '".JText::_('COM_COMPONENTBUILDER_VIEW_THE_CONTRIBUTOR_DETAILS')."';");
|
||||
$this->document->addScriptDeclaration("var lang_JCB_Community = '".JText::_('COM_COMPONENTBUILDER_JCB_COMMUNITY')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Company_Name = '".JText::_('COM_COMPONENTBUILDER_COMPANY_NAME')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Author_Name = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_NAME')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Author_Email = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_EMAIL')."';");
|
||||
$this->document->addScriptDeclaration("var lang_Author_Website = '".JText::_('COM_COMPONENTBUILDER_AUTHOR_WEBSITE')."';");
|
||||
// add some lang verfy messages
|
||||
$this->document->addScriptDeclaration("
|
||||
// set the snippet from gitHub
|
||||
function getConfirmUpdate(status) {
|
||||
switch(status) {
|
||||
case 'new':
|
||||
return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_ADD_THIS_NEW_JCB_COMMUNITY_SNIPPET_TO_YOUR_LOCAL_SNIPPETS')."';
|
||||
break;
|
||||
case 'behind':
|
||||
return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_NEWER_JCB_COMMUNITY_SNIPPET')."';
|
||||
break;
|
||||
case 'ahead':
|
||||
return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_OLDER_JCB_COMMUNITY_SNIPPET')."';
|
||||
break;
|
||||
case 'diverged':
|
||||
return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_REPLACE_YOUR_LOCAL_SNIPPET_WITH_THIS_JCB_COMMUNITY_SNIPPET')."';
|
||||
break;
|
||||
default:
|
||||
return '".JText::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_CONTINUE')."';
|
||||
break;
|
||||
}
|
||||
}
|
||||
");
|
||||
// Set the Time To Live To JavaScript
|
||||
$this->document->addScriptDeclaration("var expire = ". (int) $expire.";");
|
||||
// load the local snippets
|
||||
@ -194,7 +242,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
getSnippets('https://api.github.com/repos/vdm-io/Joomla-Component-Builder-Snippets/git/trees/master');
|
||||
});
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('body').on('click','.getmodal',function(){
|
||||
jQuery('body').on('click','.getreaction',function(){
|
||||
// Ajax request
|
||||
var btn = jQuery(this);
|
||||
btn.prop('disabled', true);
|
||||
@ -203,7 +251,12 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
}, 3000);
|
||||
var path = btn.data('path');
|
||||
var type = btn.data('type');
|
||||
getSnippetModal(path, type);
|
||||
if ('get' === type) {
|
||||
var status = btn.data('status');
|
||||
setSnippetGithub(path, status);
|
||||
} else {
|
||||
getSnippetModal(path, type);
|
||||
}
|
||||
});
|
||||
});
|
||||
// load every thing once ready
|
||||
@ -211,7 +264,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
if (0 === jQuery.active) {
|
||||
setTimeout( function() {
|
||||
//do something special
|
||||
jQuery('#snippets-github').html('<h1>Snippets</h1>');
|
||||
jQuery('#snippets-github').html('<h1>'+lang_Snippets+'</h1>');
|
||||
jQuery('#snippets-display').show();
|
||||
jQuery('#snippets-grid').trigger('display.uk.check');
|
||||
}, 1000);
|
||||
@ -240,9 +293,9 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
if (local_modified == modified) {
|
||||
return 'equal';
|
||||
} else if (local_modified > modified) {
|
||||
return 'behind';
|
||||
} else if (local_modified < modified) {
|
||||
return 'ahead';
|
||||
} else if (local_modified < modified) {
|
||||
return 'behind';
|
||||
}
|
||||
}
|
||||
return 'diverged';
|
||||
@ -255,7 +308,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
var _paths = jQuery.jStorage.get('JCB-Snippets-Paths', null);
|
||||
if (_paths) {
|
||||
setSnippets(_paths);
|
||||
jQuery('#snippets-github').html('<h1>Snippets</h1>');
|
||||
jQuery('#snippets-github').html('<h1>'+lang_Snippets+'</h1>');
|
||||
jQuery('#snippets-display').show();
|
||||
} else {
|
||||
jQuery.get(path)
|
||||
@ -295,26 +348,139 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
|
||||
// set the snippets
|
||||
function setSnippet(snippet, key) {
|
||||
// get useful ID
|
||||
var keyID = getKeyID(key);
|
||||
// get the status
|
||||
var status = getSnippetStatus(snippet, key);
|
||||
// build the snippet display
|
||||
var html = '<div class=\"uk-panel\" data-uk-filter=\"'+status+'\" data-snippet-libraries=\"'+snippet.library+'\" data-snippet-types=\"'+snippet.type+'\" data-snippet-name=\"'+snippet.name+'\">';
|
||||
var html = '<div id=\"'+keyID+'-panel\" class=\"uk-panel\" data-uk-filter=\"'+status+'\" data-snippet-libraries=\"'+snippet.library+'\" data-snippet-types=\"'+snippet.type+'\" data-snippet-name=\"'+snippet.name+'\">';
|
||||
html += '<div class=\"uk-panel uk-panel-box uk-width-1-1\">';
|
||||
html += '<div class=\"uk-panel-badge uk-badge\">'+status+'</div><br />';
|
||||
html += '<div id=\"'+keyID+'-badge\" class=\"uk-panel-badge uk-badge\">'+status+'</div><br />';
|
||||
html += '<h3 class=\"uk-panel-title\">' + snippet.library+ ' - (' + snippet.type + ') ' + snippet.name + '</h3>';
|
||||
html += snippet.heading + '<hr />';
|
||||
html += '<div class=\"uk-button-group uk-width-1-1 uk-margin-small-bottom\">';
|
||||
html += '<button class=\"uk-button uk-button-success uk-width-1-3 getmodal\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"usage\">Usage</button>';
|
||||
html += '<button class=\"uk-button uk-button-success uk-width-1-3 getmodal\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"description\">Description</button>';
|
||||
html += '<button class=\"uk-button uk-button-success uk-width-1-3 getmodal\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"snippet\">Snippet</button>';
|
||||
html += '</div>';
|
||||
html += '<div><a class=\"uk-button uk-button-mini uk-button-success uk-width-1-1\" href=\"'+snippet.url+'\" target=\"_blank\">' + snippet.name + '</a></div>';
|
||||
// set the data buttons
|
||||
html += setDataButtons(snippet, key, status)
|
||||
// set the snippet ref button
|
||||
html += setRefButtons(snippet, key, status, keyID)
|
||||
// set the contributor buttons
|
||||
html += setContributorButtons(snippet, key);
|
||||
// close the box panel
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
// now we have the snippet
|
||||
jQuery('#snippets-grid').append(html);
|
||||
}
|
||||
|
||||
function setDataButtons(snippet, key, status) {
|
||||
var html = '<div class=\"uk-button-group uk-width-1-1 uk-margin-small-bottom\">';
|
||||
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"usage\" data-uk-tooltip title=\"'+lang_Usage_Tooltip+'\"><i class=\"uk-icon-info\"></i> '+lang_Usage+'</button>';
|
||||
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"description\" data-uk-tooltip title=\"'+lang_Description_Tooltip+'\"><i class=\"uk-icon-sticky-note-o\"></i> '+lang_Description+'</button>';
|
||||
html += '<button class=\"uk-button uk-button-small uk-button-success uk-width-1-3 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"snippet\" data-uk-tooltip title=\"'+lang_Snippet_Tooltip+'\"><i class=\"uk-icon-code\"></i> '+lang_Snippet+'</button>';
|
||||
html += '</div>';
|
||||
// return data buttons
|
||||
return html;
|
||||
}
|
||||
|
||||
function setRefButtons(snippet, key, status, keyID) {
|
||||
var html = '<div><a class=\"uk-button uk-button-mini uk-button-success uk-margin-small-bottom uk-width-1-1\" href=\"'+snippet.url+'\" target=\"_blank\" data-uk-tooltip title=\"'+lang_URL_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> ' + snippet.name + '</a></div>';
|
||||
// set the update and review button
|
||||
html += '<div class=\"uk-button-group uk-width-1-1 uk-margin-small-bottom\">';
|
||||
html += '<a class=\"uk-button uk-button-small uk-button-primary uk-width-1-2\" href=\"https://github.com/vdm-io/Joomla-Component-Builder-Snippets/blame/master/'+key+'\" target=\"_blank\" data-uk-tooltip title=\"'+lang_View_Blame_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> '+lang_View_Blame+'</a>';
|
||||
if ('equal' !== status) {
|
||||
if ('new' === status) {
|
||||
var tooltip = lang_Get_Snippet_New_Tooltip;
|
||||
} else {
|
||||
var tooltip = lang_Get_Snippet_Tooltip;
|
||||
}
|
||||
html += '<button id=\"'+keyID+'-getbutton\" class=\"uk-button uk-button-small uk-button-primary uk-width-1-2 getreaction\" data-status=\"'+status+'\" data-path=\"'+key+'\" data-type=\"get\" data-uk-tooltip title=\"'+tooltip+'\"><i class=\"uk-icon-cloud-download\"></i> '+lang_Get_Snippet+'</button>';
|
||||
} else {
|
||||
html += '<button class=\"uk-button uk-button-small uk-width-1-2\" type=\"button\" disabled data-uk-tooltip title=\"'+lang_Get_Snippet_Dont_Tooltip+'\"><i class=\"uk-icon-cloud-download\"></i> '+lang_Get_Snippet+'</button>';
|
||||
}
|
||||
html += '</div>';
|
||||
// return data buttons
|
||||
return html;
|
||||
}
|
||||
|
||||
function setContributorButtons(snippet, key) {
|
||||
// set the contributor name
|
||||
if (snippet.contributor_company) {
|
||||
var contributor_name = snippet.contributor_company;
|
||||
} else if (snippet.contributor_name) {
|
||||
var contributor_name = snippet.contributor_name;
|
||||
} else {
|
||||
var contributor_name = lang_JCB_Community;
|
||||
}
|
||||
// set the contributor url
|
||||
if (snippet.contributor_website) {
|
||||
var contributor_url = snippet.contributor_website;
|
||||
} else if (snippet.contributor_email) {
|
||||
var contributor_url = 'mailto:'+snippet.contributor_email;
|
||||
} else {
|
||||
var contributor_url = 'https://github.com/vdm-io/Joomla-Component-Builder-Snippets';
|
||||
}
|
||||
var html = '<div class=\"uk-button-group uk-width-1-1\">';
|
||||
html += '<button class=\"uk-button uk-width-1-5 uk-button-mini getreaction\" data-type=\"contributor\" data-path=\"'+key+'\" data-uk-tooltip title=\"'+lang_Contributor_Modal_Tooltip+'\"><i class=\"uk-icon-user\"></i></button>';
|
||||
html += '<a class=\"uk-button uk-width-4-5 uk-button-mini\" href=\"'+contributor_url+'\" target=\"_blank\" data-uk-tooltip title=\"'+lang_Contributor_URL_Tooltip+'\"><i class=\"uk-icon-external-link\"></i> ' + contributor_name + '</a>';
|
||||
html += '</div>';
|
||||
// return contributor buttons
|
||||
return html;
|
||||
}
|
||||
|
||||
// set the snippet from gitHub
|
||||
function setSnippetGithub(key, status) {
|
||||
var message = getConfirmUpdate(status);
|
||||
UIkit.modal.confirm(message, function(){
|
||||
// will be executed on confirm.
|
||||
setSnippetGithub_server(key, status).done(function(result) {
|
||||
if (result.message) {
|
||||
UIkit.notify(result.message, {status: result.status});
|
||||
if ('success' === result.status) {
|
||||
// get key ID
|
||||
var keyID = getKeyID(key);
|
||||
// update snippet if we can
|
||||
updateSnippetDisplay(keyID, 'equal');
|
||||
}
|
||||
} else {
|
||||
UIkit.notify(lang_Update_Error_Tooltip, {status:'danger'});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function setSnippetGithub_server(path, status) {
|
||||
var getUrl = \"index.php?option=com_componentbuilder&task=ajax.setSnippetGithub&format=json\";
|
||||
if (token.length > 0 && path.length > 0 && status.length > 0) {
|
||||
var request = 'token='+token+'&path='+path+'&status='+status;
|
||||
}
|
||||
return jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: getUrl,
|
||||
dataType: 'jsonp',
|
||||
data: request,
|
||||
jsonp: 'callback'
|
||||
});
|
||||
}
|
||||
|
||||
// update the snippet display
|
||||
function updateSnippetDisplay(keyID, status) {
|
||||
// update badge
|
||||
jQuery('#'+keyID+'-badge').html(status);
|
||||
// update button
|
||||
if ('equal' === status) {
|
||||
// update notice
|
||||
jQuery('#'+keyID+'-getbutton').attr('title', lang_Get_Snippet_Dont_Tooltip);
|
||||
jQuery('#'+keyID+'-getbutton').prop('disabled', true);
|
||||
// counter delay just incase
|
||||
setTimeout(function(){
|
||||
jQuery('#'+keyID+'-getbutton').prop('disabled', true);
|
||||
}, 2000);
|
||||
}
|
||||
// update the data filter
|
||||
jQuery('#'+keyID+'-panel').attr('data-uk-filter', status);
|
||||
// tell the grid to update
|
||||
jQuery('#snippets-grid').trigger('display.uk.check');
|
||||
}
|
||||
|
||||
// set the modal
|
||||
function getSnippetModal(key, type) {
|
||||
var _snippet = jQuery.jStorage.get(key, null);
|
||||
@ -341,14 +507,46 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy
|
||||
var html = '<div class=\"uk-modal-dialog uk-modal-dialog-lightbox\">';
|
||||
html += '<a href=\"\" class=\"uk-modal-close uk-close uk-close-alt\"></a>';
|
||||
html += '<h3>' + snippet.library + ' - (' + snippet.type + ') ' + snippet.name + '</h3>';
|
||||
html += '<br /><textarea class=\"uk-width-1-1\" rows=\"15\">'+snippet[type]+'</textarea>';
|
||||
if ('contributor' === type) {
|
||||
html += '<dl class=\"uk-description-list-line\">';
|
||||
html += '<dt><i class=\"uk-icon-institution\"></i> '+lang_Company_Name+'</dt>';
|
||||
html += '<dd>'+snippet.contributor_company+'</dd>';
|
||||
html += '<dt><i class=\"uk-icon-user\"></i> '+lang_Author_Name+'</dt>';
|
||||
html += '<dd>'+snippet.contributor_name+'</dd>';
|
||||
html += '<dt><i class=\"uk-icon-envelope-o\"></i> '+lang_Author_Email+'</dt>';
|
||||
html += '<dd>'+snippet.contributor_email+'</dd>';
|
||||
html += '<dt><i class=\"uk-icon-laptop\"></i> '+lang_Author_Website+'</dt>';
|
||||
html += '<dd>'+snippet.contributor_website+'</dd>';
|
||||
html += '</dl>';
|
||||
} else {
|
||||
html += '<br /><textarea class=\"uk-width-1-1\" rows=\"15\" readonly>'+snippet[type]+'</textarea>';
|
||||
}
|
||||
html += '<br /><small>C: ' + snippet.created + ' | M: ' + snippet.modified + '</small>';
|
||||
html += '</div>';
|
||||
// get current page position
|
||||
var scroll = jQuery(window).scrollTop();
|
||||
// add html to modal
|
||||
var modal = UIkit.modal.blockUI(html);
|
||||
var modal = UIkit.modal.blockUI(html, {center:true, bgclose:true}).on({
|
||||
'hide.uk.modal': function(){
|
||||
// scroll fix since the modal pops to the top of the page
|
||||
jQuery(window).scrollTop(scroll);
|
||||
}
|
||||
});
|
||||
// show modal
|
||||
modal.show();
|
||||
}
|
||||
|
||||
// get key ID
|
||||
function getKeyID(key) {
|
||||
// get useful ID
|
||||
keyID = key.replace('-', '');
|
||||
keyID = keyID.replace('.json', '');
|
||||
keyID = keyID.replace(/\s+/ig, '-');
|
||||
keyID = keyID.replace(/\(/g, '');
|
||||
keyID = keyID.replace(/\)/g, '');
|
||||
// return the id build
|
||||
return keyID;
|
||||
}
|
||||
");
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="3.2" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>16th November, 2017</creationDate>
|
||||
<creationDate>17th November, 2017</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>joomla@vdm.io</authorEmail>
|
||||
<authorUrl>http://vdm.bz/component-builder</authorUrl>
|
||||
|
Loading…
Reference in New Issue
Block a user